Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2022-12-13 04:07:14
Exec Total Coverage
Lines: 8802 16611 53.0%
Functions: 215 316 68.0%
Branches: 7099 19758 35.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #ifndef __GTHREAD_HIDE_WIN32API
16 11 #define __GTHREAD_HIDE_WIN32API 1
17 #endif //prevent indirectly including windows.h
18
19 #include "precompiled.h" //always first
20
21 #include <string.h>
22 #include <set>
23 #include <stdio.h>
24
25 #include "hero.h"
26 #include "guys.h"
27 #include "subscr.h"
28 #include "zc_subscr.h"
29 #include "decorations.h"
30 #include "gamedata.h"
31 #include "zc_custom.h"
32 #include "title.h"
33 #include "ffscript.h"
34 #include "drawing.h"
35 #include "combos.h"
36 #include "base/zc_math.h"
37 #include "user_object.h"
38 #include "slopes.h"
39 extern FFScript FFCore;
40 extern word combo_doscript[176];
41 extern byte itemscriptInitialised[256];
42 extern HeroClass Hero;
43 extern ZModule zcm;
44 extern zcmodule moduledata;
45 extern refInfo playerScriptData;
46 #include "zscriptversion.h"
47 #include "particles.h"
48 #include <fmt/format.h>
49
50 extern refInfo itemScriptData[256];
51 extern refInfo itemCollectScriptData[256];
52 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
53 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
54 extern refInfo *ri; //= NULL;
55 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
56 extern byte dmapscriptInitialised;
57 extern word item_doscript[256];
58 extern word item_collect_doscript[256];
59 extern portal* mirror_portal;
60 using std::set;
61
62 extern int32_t skipcont;
63
64 extern int32_t draw_screen_clip_rect_x1;
65 extern int32_t draw_screen_clip_rect_x2;
66 extern int32_t draw_screen_clip_rect_y1;
67 extern int32_t draw_screen_clip_rect_y2;
68 extern word global_wait;
69 extern bool player_waitdraw;
70 extern bool dmap_waitdraw;
71 extern bool passive_subscreen_waitdraw;
72 extern bool active_subscreen_waitdraw;
73
74 int32_t hero_count = -1;
75 int32_t hero_animation_speed = 1; //lower is faster animation
76 int32_t z3step = 2;
77 11 static zfix hero_newstep(1.5);
78 11 static zfix hero_newstep_diag(1.5);
79 bool did_scripta=false;
80 bool did_scriptb=false;
81 bool did_scriptl=false;
82 byte lshift = 0;
83 int32_t dowpn = -1;
84 int32_t directItem = -1; //Is set if Hero is currently using an item directly
85 int32_t directItemA = -1;
86 int32_t directItemB = -1;
87 int32_t directItemX = -1;
88 int32_t directItemY = -1;
89 int32_t directWpn = -1;
90 int32_t whistleitem=-1;
91 extern word g_doscript;
92 extern word player_doscript;
93 extern word dmap_doscript;
94 extern word passive_subscreen_doscript;
95 extern byte epilepsyFlashReduction;
96 extern int32_t script_hero_cset;
97
98 void playLevelMusic();
99
100 extern particle_list particles;
101
102 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
103
104 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
105 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
106 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
107 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
108
109 5963585 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
110 {
111
2/2
✓ Branch 0 taken 9138 times.
✓ Branch 1 taken 5954447 times.
5963585 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
112 5954447 return false;
113 5963585 }
114
115 1992045 static inline bool platform_fallthrough(bool doslopecheck = true)
116 {
117
5/6
✓ Branch 0 taken 1992045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1986809 times.
✓ Branch 3 taken 5236 times.
✓ Branch 4 taken 1984711 times.
✓ Branch 5 taken 2098 times.
5401497 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
118
2/2
✓ Branch 0 taken 289316 times.
✓ Branch 1 taken 284080 times.
1992045 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
119
6/6
✓ Branch 0 taken 1418028 times.
✓ Branch 1 taken 1707344 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 1991263 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 23 times.
573396 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
120 }
121
122 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
123 {
124 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
125 if(slopesmisc == 2) return false;
126 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
127 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
128 if (platform_fallthrough() && !ignoreFallthrough) return false;
129 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
130 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
131 return true;
132 return false;
133 }
134
135 2525267 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
136 {
137
4/4
✓ Branch 0 taken 76694 times.
✓ Branch 1 taken 2448573 times.
✓ Branch 2 taken 54591 times.
✓ Branch 3 taken 22103 times.
2525267 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
138
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 2501194 times.
2503164 if(slopesmisc == 2) return false;
139
4/4
✓ Branch 0 taken 2032982 times.
✓ Branch 1 taken 468212 times.
✓ Branch 2 taken 40510 times.
✓ Branch 3 taken 1992472 times.
2501194 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
140
6/6
✓ Branch 0 taken 2623 times.
✓ Branch 1 taken 1989849 times.
✓ Branch 2 taken 554 times.
✓ Branch 3 taken 2069 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 429 times.
1992472 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
141
4/4
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 1991399 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 551 times.
1992043 if (platform_fallthrough() && !ignoreFallthrough) return false;
142
4/4
✓ Branch 0 taken 35728 times.
✓ Branch 1 taken 1955764 times.
✓ Branch 2 taken 34074 times.
✓ Branch 3 taken 1654 times.
1991492 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
143
6/6
✓ Branch 0 taken 582047 times.
✓ Branch 1 taken 1407791 times.
✓ Branch 2 taken 560128 times.
✓ Branch 3 taken 21919 times.
✓ Branch 4 taken 196 times.
✓ Branch 5 taken 559932 times.
1989838 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
144 22115 return true;
145 1967723 return false;
146 2525267 }
147
148
149 7084114 bool usingActiveShield(int32_t itmid)
150 {
151
2/2
✓ Branch 0 taken 5795498 times.
✓ Branch 1 taken 1288616 times.
7084114 switch(Hero.action) //filter allowed actions
152 {
153 case none: case walking: case rafting:
154 case gothit: case swimhit:
155 5795498 break;
156 1288616 default: return false;
157 }
158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5795498 times.
5795498 if(itmid < 0)
159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5795498 times.
5795498 itmid = (Hero.active_shield_id < 0
160 5795498 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
161
2/2
✓ Branch 0 taken 5772468 times.
✓ Branch 1 taken 23030 times.
5795498 if(itmid < 0) return false;
162
1/2
✓ Branch 0 taken 5772468 times.
✗ Branch 1 not taken.
5772468 if(!checkitem_jinx(itmid)) return false;
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5772468 times.
5772468 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
164 if(!isItmPressed(itmid)) return false;
165 return (checkbunny(itmid) && checkmagiccost(itmid));
166 7084114 }
167 4214784 int32_t getCurrentShield(bool requireActive)
168 {
169
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4214784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4214784 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
170 return Hero.active_shield_id;
171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4214784 times.
4214784 if(!requireActive) return current_item_id(itype_shield);
172 return -1;
173 4214784 }
174 6732 int32_t getCurrentActiveShield()
175 {
176 6732 int32_t id = Hero.active_shield_id;
177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6732 if(id > -1 && usingActiveShield(id))
178 return id;
179 6732 return -1;
180 6732 }
181 2441646 int32_t refreshActiveShield()
182 {
183 2441646 int32_t id = -1;
184
2/2
✓ Branch 0 taken 2349981 times.
✓ Branch 1 taken 91665 times.
2441646 if(DrunkcBbtn())
185 {
186 91665 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 91665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
91665 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
188 {
189 id = Bwpn&0xFFF;
190 }
191 91665 }
192
3/4
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2089889 times.
✓ Branch 3 taken 351757 times.
2441646 if(id < 0 && DrunkcAbtn())
193 {
194 351757 itemdata const& dat = itemsbuf[Awpn&0xFFF];
195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 351757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351757 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
196 {
197 id = Awpn&0xFFF;
198 }
199 351757 }
200
2/4
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441646 times.
✗ Branch 3 not taken.
2441646 if(id < 0 && DrunkcEx1btn())
201 {
202 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
203 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
204 {
205 id = Xwpn&0xFFF;
206 }
207 }
208
2/4
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441646 times.
✗ Branch 3 not taken.
2441646 if(id < 0 && DrunkcEx2btn())
209 {
210 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
211 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
212 {
213 id = Ywpn&0xFFF;
214 }
215 }
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441646 times.
2441646 if(!usingActiveShield(id))
217 2441646 return -1;
218 return id;
219 2441646 }
220 static bool is_immobile()
221 {
222 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
223 return false;
224 zfix rate(Hero.steprate);
225 int32_t shieldid = getCurrentActiveShield();
226 if(shieldid > -1)
227 {
228 itemdata const& shield = itemsbuf[shieldid];
229 if(shield.flags & ITEM_FLAG10) //Change Speed flag
230 {
231 zfix perc = shield.misc7;
232 perc /= 100;
233 if(perc < 0)
234 perc = (perc*-1)+1;
235 rate = (rate * perc) + shield.misc8;
236 }
237 }
238 return rate != 0;
239 }
240
241 2450844 bool HeroClass::isStanding(bool forJump)
242 {
243
11/14
✓ Branch 0 taken 2450604 times.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 2450604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12204 times.
✓ Branch 5 taken 2438400 times.
✓ Branch 6 taken 3848 times.
✓ Branch 7 taken 8356 times.
✓ Branch 8 taken 3848 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3848 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 557 times.
✓ Branch 13 taken 3291 times.
2450844 bool st = (z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !ladderx && !laddery && !getOnSideviewLadder()) && hoverclk==0);
244
2/2
✓ Branch 0 taken 2447313 times.
✓ Branch 1 taken 3531 times.
2450844 if(!st) return false;
245 2447313 int32_t val = check_pitslide();
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2447313 times.
2447313 if(val == -2) return false;
247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2447313 times.
2447313 if(val == -1) return true;
248 return forJump;
249 2450844 }
250 9332 bool HeroClass::isLifting()
251 {
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 if(lift_wpn) return true;
253 9332 return false;
254 9332 }
255
256 16384 void HeroClass::set_respawn_point(bool setwarp)
257 {
258
2/2
✓ Branch 0 taken 12899 times.
✓ Branch 1 taken 3485 times.
16384 if(setwarp)
259 {
260 3485 warpx = x;
261 3485 warpy = y;
262 3485 raftwarpx = x;
263 3485 raftwarpy = y;
264 3485 }
265
2/2
✓ Branch 0 taken 6829 times.
✓ Branch 1 taken 9555 times.
16384 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
266 {
267
2/2
✓ Branch 0 taken 9330 times.
✓ Branch 1 taken 225 times.
9555 switch(action)
268 {
269 case none: case walking:
270 9330 break;
271 default:
272 225 return; //Not a 'safe action'
273 }
274
4/6
✓ Branch 0 taken 9210 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 9210 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9210 times.
9330 if(z > 0 || fakez > 0 || hoverclk) return; //in air
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9210 times.
9210 if(check_pitslide(true) != -1) return; //On a pit
276
277 { //Check water
278 9210 int32_t water = 0;
279 9210 int32_t types[4] = {0};
280 9210 int32_t x1 = x+4, x2 = x+11,
281 9210 y1 = y+9, y2 = y+15;
282
1/2
✓ Branch 0 taken 9210 times.
✗ Branch 1 not taken.
9210 if (get_bit(quest_rules, qr_SMARTER_WATER))
283 {
284
3/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 9163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
9214 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
285
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 43 times.
47 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
286
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
287 4 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
288 9210 }
289 else
290 {
291 types[0] = COMBOTYPE(x1,y1);
292
293 if(MAPFFCOMBO(x1,y1))
294 types[0] = FFCOMBOTYPE(x1,y1);
295
296 types[1] = COMBOTYPE(x1,y2);
297
298 if(MAPFFCOMBO(x1,y2))
299 types[1] = FFCOMBOTYPE(x1,y2);
300
301 types[2] = COMBOTYPE(x2,y1);
302
303 if(MAPFFCOMBO(x2,y1))
304 types[2] = FFCOMBOTYPE(x2,y1);
305
306 types[3] = COMBOTYPE(x2,y2);
307
308 if(MAPFFCOMBO(x2,y2))
309 types[3] = FFCOMBOTYPE(x2,y2);
310
311 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
312 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
313 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
314
315 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
316 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
317 water = typec;
318 }
319
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9206 times.
9210 if(water > 0)
320 {
321 4 return;
322 }
323 } //End check water
324
325 46030 int poses[4] = {
326 9206 COMBOPOS(x,y+(bigHitbox?0:8)),
327 9206 COMBOPOS(x,y+15),
328 9206 COMBOPOS(x+15,y+(bigHitbox?0:8)),
329 9206 COMBOPOS(x+15,y+15)
330 };
331
2/2
✓ Branch 0 taken 36824 times.
✓ Branch 1 taken 9206 times.
46030 for(auto pos : poses)
332 {
333
1/2
✓ Branch 0 taken 36824 times.
✗ Branch 1 not taken.
36824 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
334 return;
335 }
336 9206 }
337 16035 respawn_x = x;
338 16035 respawn_y = y;
339 16035 respawn_scr = currscr;
340 16035 respawn_dmap = currdmap;
341 16384 }
342
343 3 void HeroClass::go_respawn_point()
344 {
345 3 x = respawn_x;
346 3 y = respawn_y;
347 3 can_mirror_portal = false; //incase entry is on a portal!
348 3 warpx=x;
349 3 warpy=y;
350 3 raftwarpx = x;
351 3 raftwarpy = y;
352 3 trySideviewLadder(); //Cling to ladder automatically
353
354
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
355 return; //No cross-screen return
356
357
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if(currdmap != respawn_dmap || currscr != respawn_scr)
358 {
359 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
360 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
361 }
362 3 }
363
364 3836 void HeroClass::trySideviewLadder()
365 {
366
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3836 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3836 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
367 setOnSideviewLadder(true);
368 3836 }
369
370 11228724 bool HeroClass::can_pitfall(bool ignore_hover)
371 {
372
25/30
✓ Branch 0 taken 11199365 times.
✓ Branch 1 taken 29359 times.
✓ Branch 2 taken 11161646 times.
✓ Branch 3 taken 37719 times.
✓ Branch 4 taken 11161406 times.
✓ Branch 5 taken 240 times.
✓ Branch 6 taken 11161406 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11161394 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 11161394 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11161394 times.
✓ Branch 14 taken 11155123 times.
✓ Branch 15 taken 6271 times.
✓ Branch 16 taken 11154442 times.
✓ Branch 17 taken 681 times.
✓ Branch 18 taken 11154244 times.
✓ Branch 19 taken 198 times.
✓ Branch 20 taken 11154244 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 10942705 times.
✓ Branch 23 taken 211539 times.
✓ Branch 24 taken 10942425 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 10942425 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 768 times.
✓ Branch 29 taken 10941657 times.
11228724 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
373 }
374
375 1394762 int32_t HeroClass::DrunkClock()
376 {
377 1394762 return drunkclk;
378 }
379 void HeroClass::setDrunkClock(int32_t newdrunkclk)
380 {
381 drunkclk=newdrunkclk;
382 }
383
384 int32_t HeroClass::StunClock()
385 {
386 return lstunclock;
387 }
388 void HeroClass::setStunClock(int32_t v)
389 {
390 lstunclock=v;
391 }
392
393 35361640 int32_t HeroClass::BunnyClock()
394 {
395 35361640 return lbunnyclock;
396 }
397 void HeroClass::setBunnyClock(int32_t v)
398 {
399 lbunnyclock=v;
400 }
401
402
9/18
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 11 times.
✗ Branch 17 not taken.
44 HeroClass::HeroClass() : sprite()
403 33 {
404 11 lift_wpn = nullptr;
405
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 init();
406 22 }
407
408 //2.6
409
410 //Stop the subscreen from falling. -Z
411
412 278 bool HeroClass::stopSubscreenFalling(){
413 278 return preventsubscreenfalling;
414 }
415
416 void HeroClass::stopSubscreenFalling(bool v){
417 preventsubscreenfalling = v;
418 }
419
420
421 //Set the button items by brute force
422
423 void HeroClass::setAButtonItem(int32_t itmslot){
424 game->awpn = itmslot;
425 }
426
427 void HeroClass::setBButtonItem(int32_t itmslot){
428 game->bwpn = itmslot;
429 }
430
431 2441884 void HeroClass::ClearhitHeroUIDs()
432 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
433 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
434 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
435 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
436 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
437 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
438 //clear it on the next frame, but that had the SAME outcome.
439 //Where and how can I clear a value at the end of every frame, so that:
440 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
441 // 2. FFCs can read it before Waitframe. --same.
442 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
443
2/2
✓ Branch 0 taken 19535072 times.
✓ Branch 1 taken 2441884 times.
21976956 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED_PLAYER; q++ )
444 {
445 /*
446 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
447 {
448 //Z_scripterrlog("frame is: %d\n", frame);
449 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
450 lastHitBy[q][0] = 0;
451 }
452 */
453 19535072 lastHitBy[q][0] = 0;
454 19535072 }
455 2441884 }
456
457 6326 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
458 {
459 6326 lastHitBy[type][0] = screen_index;
460 //lastHitBy[type][1] = frame;
461 /* Let's figure out how to clear this...
462 if ( global_wait ) lastHitBy[type] = screen_index;
463 else lastHitBy[type] = 0;
464 //No, we clear it in Zelda.cpp, with this:
465 if(global_wait)
466 {
467 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
468 global_wait=false;
469 }
470
471
472 draw_screen(tmpscr);
473
474 //clear Hero's last hits
475 //for ( int32_t q = 0; q < 4; q++ ) Hero.sethitHeroUID(q, 0);
476
477 */
478
479 6326 }
480
481 int32_t HeroClass::gethitHeroUID(int32_t type)
482 {
483 return lastHitBy[type][0];
484 }
485
486 void HeroClass::set_defence(int32_t type, int32_t v)
487 {
488 defence[type] = v;
489 }
490
491 int32_t HeroClass::get_defence(int32_t type)
492 {
493 return defence[type];
494 }
495
496
497 //Set Hero;s hurt sfx
498 void HeroClass::setHurtSFX(int32_t sfx)
499 {
500 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
501 }
502 3209 int32_t HeroClass::getHurtSFX()
503 {
504 3209 return QMisc.miscsfx[sfxHURTPLAYER];
505 }
506
507 bool HeroClass::getDiagMove()
508 {
509 return diagonalMovement;
510 }
511 void HeroClass::setDiagMove(bool newdiag)
512 {
513 diagonalMovement=newdiag;
514 }
515 bool HeroClass::getBigHitbox()
516 {
517 return bigHitbox;
518 }
519 112 void HeroClass::setBigHitbox(bool newbigHitbox)
520 {
521 112 bigHitbox=newbigHitbox;
522 112 syofs = bigHitbox?0:8;
523 112 sysz_ofs = bigHitbox?0:-8;
524 112 }
525 int32_t HeroClass::getStepRate()
526 {
527 return steprate;
528 }
529 void HeroClass::setStepRate(int32_t newrate)
530 {
531 steprate = newrate;
532 }
533 int32_t HeroClass::getSwimUpRate()
534 {
535 return game->get_sideswim_up();
536 }
537 void HeroClass::setSwimUpRate(int32_t newrate)
538 {
539 game->set_sideswim_up(newrate);
540 }
541 int32_t HeroClass::getSwimSideRate()
542 {
543 return game->get_sideswim_side();
544 }
545 void HeroClass::setSwimSideRate(int32_t newrate)
546 {
547 game->set_sideswim_side(newrate);
548 }
549 int32_t HeroClass::getSwimDownRate()
550 {
551 return game->get_sideswim_down();
552 }
553 void HeroClass::setSwimDownRate(int32_t newrate)
554 {
555 game->set_sideswim_down(newrate);
556 }
557
558
559 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
560 1794432 void HeroClass::herostep()
561 {
562
2/2
✓ Branch 0 taken 1635216 times.
✓ Branch 1 taken 159216 times.
1794432 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
563 //need to run all global/hero/dmap scripts here?
564 1794432 }
565
566 13089 bool is_moving()
567 {
568
6/6
✓ Branch 0 taken 11958 times.
✓ Branch 1 taken 1131 times.
✓ Branch 2 taken 9826 times.
✓ Branch 3 taken 2132 times.
✓ Branch 4 taken 4724 times.
✓ Branch 5 taken 5102 times.
13089 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
569 }
570
571 // called by ALLOFF()
572 4597 void HeroClass::resetflags(bool all)
573 {
574 4597 refilling=REFILL_NONE;
575 4597 inwallm=false;
576 4597 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
577 4597 usecounts.clear();
578
579
4/4
✓ Branch 0 taken 4579 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 4510 times.
4597 if(swordclk>0 || all)
580 {
581 87 swordclk=0;
582 87 verifyAWpn();
583 87 }
584
4/4
✓ Branch 0 taken 4592 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 4523 times.
4597 if(itemclk>0 || all)
585 74 itemclk=0;
586
587
2/2
✓ Branch 0 taken 4528 times.
✓ Branch 1 taken 69 times.
4597 if(all)
588 {
589 69 NayrusLoveShieldClk=0;
590
591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(nayruitem != -1)
592 {
593 stop_sfx(itemsbuf[nayruitem].usesound);
594 stop_sfx(itemsbuf[nayruitem].usesound+1);
595 }
596
597 69 nayruitem = -1;
598 69 hoverclk=jumping=0;
599 69 hoverflags = 0;
600 69 }
601 4597 damageovertimeclk = 0;
602 4597 newconveyorclk = 0;
603 4597 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
604
2/2
✓ Branch 0 taken 4597 times.
✓ Branch 1 taken 32179 times.
36776 for(auto q = 0; q < 7; ++q)
605 32179 hooked_undercombos[q] = -1;
606 4597 hopclk=0;
607 4597 hopdir=-1;
608 4597 attackclk=0;
609 4597 stomping=false;
610 4597 reset_swordcharge();
611 4597 diveclk=drownclk=drownCombo=0;
612 4597 action=none; FFCore.setHeroAction(none);
613 4597 conveyor_flags=0;
614 4597 magiccastclk=0;
615 4597 magicitem=-1;
616 4597 }
617
618 //Can use this for Hero->Stun. -Z
619 3500 void HeroClass::Freeze()
620 {
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3500 times.
3500 if (action != inwind)
622 {
623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3500 times.
3500 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
624 3500 else {action=freeze; FFCore.setHeroAction(freeze);}
625 // also cancel Hero's attack
626 3500 attackclk = 0;
627 3500 }
628 3500 }
629 415 void HeroClass::unfreeze()
630 {
631
3/4
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
415 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
632
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
415 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
633 415 }
634
635 3 void HeroClass::Drown(int32_t state)
636 {
637 // Hero should never drown if the ladder is out
638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ladderx+laddery)
639 return;
640
641 3 drop_liftwpn();
642
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 switch(state)
643 {
644 case 1:
645 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
646 attackclk=0;
647 attack=wNone;
648 attackid=-1;
649 reset_swordcharge();
650 drownclk=64;
651 z=fakez=fall=fakefall=0;
652 break;
653
654
655 default:
656 {
657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
658 3 else {action=drowning; FFCore.setHeroAction(drowning);}
659 3 attackclk=0;
660 3 attack=wNone;
661 3 attackid=-1;
662 3 reset_swordcharge();
663 3 drownclk=64;
664 3 z=fakez=fall=fakefall=0;
665 3 break;
666 }
667 }
668
669 3 }
670
671 303 void HeroClass::finishedmsg()
672 {
673 //these are to cancel out any keys that Hero may
674 //be pressing so he doesn't attack at the end of
675 //a message if he was scrolling through it quickly.
676 303 rAbtn();
677 303 rBbtn();
678 303 unfreeze();
679
680
2/4
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
606 if(action == landhold1 ||
681
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 action == landhold2 ||
682
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 action == waterhold1 ||
683
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 action == waterhold2 ||
684
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 action == sidewaterhold1 ||
685 303 action == sidewaterhold2)
686 {
687 holdclk = 1;
688 }
689 303 }
690 17 void HeroClass::setEaten(int32_t i)
691 {
692 17 inlikelike=i;
693 17 }
694 17 int32_t HeroClass::getEaten()
695 {
696 17 return inlikelike;
697 }
698 1325688 zfix HeroClass::getX()
699 {
700 1325688 return x;
701 }
702 1053053 zfix HeroClass::getY()
703 {
704 1053053 return y;
705 }
706 17816387 zfix HeroClass::getZ()
707 {
708 17816387 return z;
709 }
710 12601171 zfix HeroClass::getFakeZ()
711 {
712 12601171 return fakez;
713 }
714 zfix HeroClass::getFall()
715 {
716 return fall;
717 }
718 zfix HeroClass::getFakeFall()
719 {
720 return fakefall;
721 }
722 zfix HeroClass::getXOfs()
723 {
724 return xofs;
725 }
726 zfix HeroClass::getYOfs()
727 {
728 return yofs;
729 }
730 void HeroClass::setXOfs(int32_t newxofs)
731 {
732 xofs=newxofs;
733 }
734 void HeroClass::setYOfs(int32_t newyofs)
735 {
736 yofs=newyofs;
737 }
738 int32_t HeroClass::getHXOfs()
739 {
740 return hxofs;
741 }
742 int32_t HeroClass::getHYOfs()
743 {
744 return hyofs;
745 }
746 int32_t HeroClass::getHXSz()
747 {
748 return hxsz;
749 }
750 int32_t HeroClass::getHYSz()
751 {
752 return hysz;
753 }
754 16576 zfix HeroClass::getClimbCoverX()
755 {
756 16576 return climb_cover_x;
757 }
758 16576 zfix HeroClass::getClimbCoverY()
759 {
760 16576 return climb_cover_y;
761 }
762 int32_t HeroClass::getLadderX()
763 {
764 return ladderx;
765 }
766 int32_t HeroClass::getLadderY()
767 {
768 return laddery;
769 }
770
771 1792 void HeroClass::setX(int32_t new_x)
772 {
773 1792 zfix dx=new_x-x;
774
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(Lwpns.idFirst(wHookshot)>-1)
775 {
776 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
777 hs_startx+=(int32_t)dx;
778 }
779
780
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(Lwpns.idFirst(wHSHandle)>-1)
781 {
782 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
783 }
784
785
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(chainlinks.Count()>0)
786 {
787 for(int32_t j=0; j<chainlinks.Count(); j++)
788 {
789 chainlinks.spr(j)->x+=dx;
790 }
791 }
792
793 1792 x=new_x;
794
795 // A kludge
796
4/4
✓ Branch 0 taken 1791 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 543 times.
1792 if(!diagonalMovement && dir<=down)
797 543 is_on_conveyor=true;
798 1792 }
799
800 1792 void HeroClass::setY(int32_t new_y)
801 {
802 1792 zfix dy=new_y-y;
803
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(Lwpns.idFirst(wHookshot)>-1)
804 {
805 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
806 hs_starty+=(int32_t)dy;
807 }
808
809
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(Lwpns.idFirst(wHSHandle)>-1)
810 {
811 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
812 }
813
814
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(chainlinks.Count()>0)
815 {
816 for(int32_t j=0; j<chainlinks.Count(); j++)
817 {
818 chainlinks.spr(j)->y+=dy;
819 }
820 }
821
822 1792 y=new_y;
823
824 // A kludge
825
4/4
✓ Branch 0 taken 1791 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 1248 times.
1792 if(!diagonalMovement && dir>=left)
826 1248 is_on_conveyor=true;
827 1792 }
828
829 void HeroClass::setZ(int32_t new_z)
830 {
831 if(isSideViewHero())
832 return;
833
834 if(z==0 && new_z > 0)
835 {
836 switch(action)
837 {
838 case swimming:
839 {
840 diveclk=0;
841 action=walking; FFCore.setHeroAction(walking);
842 break;
843 }
844
845 case waterhold1:
846 {
847 action=landhold1; FFCore.setHeroAction(landhold1);
848 break;
849 }
850
851 case waterhold2:
852 {
853 action=landhold2; FFCore.setHeroAction(landhold2);
854 break;
855 }
856
857 default:
858 if(charging) //!DIMITODO: Let Hero jump while charging sword
859 {
860 reset_swordcharge();
861 attackclk=0;
862 }
863
864 break;
865 }
866 }
867
868 z=(new_z>0 ? new_z : 0);
869 }
870
871 void HeroClass::setFakeZ(int32_t new_z)
872 {
873 if(isSideViewHero())
874 return;
875
876 if(fakez==0 && new_z > 0)
877 {
878 switch(action)
879 {
880 case swimming:
881 {
882 diveclk=0;
883 action=walking; FFCore.setHeroAction(walking);
884 break;
885 }
886
887 case waterhold1:
888 {
889 action=landhold1; FFCore.setHeroAction(landhold1);
890 break;
891 }
892
893 case waterhold2:
894 {
895 action=landhold2; FFCore.setHeroAction(landhold2);
896 break;
897 }
898
899 default:
900 if(charging) //!DIMITODO: Let Hero jump while charging sword
901 {
902 reset_swordcharge();
903 attackclk=0;
904 }
905
906 break;
907 }
908 }
909
910 fakez=(new_z>0 ? new_z : 0);
911 }
912
913 void HeroClass::setXfix(zfix new_x)
914 {
915 //Z_scripterrlog("setxdbl: %f\n",new_x);
916 zfix dx=new_x-x;
917 if(Lwpns.idFirst(wHookshot)>-1)
918 {
919 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
920 hs_startx+=(int32_t)dx;
921 }
922
923 if(Lwpns.idFirst(wHSHandle)>-1)
924 {
925 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
926 }
927
928 if(chainlinks.Count()>0)
929 {
930 for(int32_t j=0; j<chainlinks.Count(); j++)
931 {
932 chainlinks.spr(j)->x+=dx;
933 }
934 }
935
936 x=new_x;
937
938 // A kludge
939 if(!diagonalMovement && dir<=down)
940 is_on_conveyor=true;
941 }
942
943 void HeroClass::setYfix(zfix new_y)
944 {
945 zfix dy=new_y-y;
946 if(Lwpns.idFirst(wHookshot)>-1)
947 {
948 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
949 hs_starty+=(int32_t)dy;
950 }
951
952 if(Lwpns.idFirst(wHSHandle)>-1)
953 {
954 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
955 }
956
957 if(chainlinks.Count()>0)
958 {
959 for(int32_t j=0; j<chainlinks.Count(); j++)
960 {
961 chainlinks.spr(j)->y+=dy;
962 }
963 }
964
965 y=new_y;
966
967 // A kludge
968 if(!diagonalMovement && dir>=left)
969 is_on_conveyor=true;
970 }
971
972 void HeroClass::setZfix(zfix new_z)
973 {
974 if(isSideViewHero())
975 return;
976
977 if(z==0 && new_z > 0)
978 {
979 switch(action)
980 {
981 case swimming:
982 {
983 diveclk=0;
984 action=walking; FFCore.setHeroAction(walking);
985 break;
986 }
987
988 case waterhold1:
989 {
990 action=landhold1; FFCore.setHeroAction(landhold1);
991 break;
992 }
993
994 case waterhold2:
995 {
996 action=landhold2; FFCore.setHeroAction(landhold2);
997 break;
998 }
999
1000 default:
1001 if(charging) //!DIMITODO: Let Hero jump while charging sword
1002 {
1003 reset_swordcharge();
1004 attackclk=0;
1005 }
1006
1007 break;
1008 }
1009 }
1010
1011 z=(new_z>0 ? new_z : zfix(0));
1012 }
1013
1014 void HeroClass::setFakeZfix(zfix new_z)
1015 {
1016 if(isSideViewHero())
1017 return;
1018
1019 if(fakez==0 && new_z > 0)
1020 {
1021 switch(action)
1022 {
1023 case swimming:
1024 {
1025 diveclk=0;
1026 action=walking; FFCore.setHeroAction(walking);
1027 break;
1028 }
1029
1030 case waterhold1:
1031 {
1032 action=landhold1; FFCore.setHeroAction(landhold1);
1033 break;
1034 }
1035
1036 case waterhold2:
1037 {
1038 action=landhold2; FFCore.setHeroAction(landhold2);
1039 break;
1040 }
1041
1042 default:
1043 if(charging) //!DIMITODO: Let Hero jump while charging sword
1044 {
1045 reset_swordcharge();
1046 attackclk=0;
1047 }
1048
1049 break;
1050 }
1051 }
1052
1053 fakez=(new_z>0 ? new_z : zfix(0));
1054 }
1055
1056 39 void HeroClass::setFall(zfix new_fall)
1057 {
1058 39 fall=new_fall;
1059 39 jumping=-1;
1060 39 }
1061 void HeroClass::setFakeFall(zfix new_fall)
1062 {
1063 fakefall=new_fall;
1064 jumping=-1;
1065 }
1066 void HeroClass::setClimbCoverX(int32_t new_x)
1067 {
1068 climb_cover_x=new_x;
1069 }
1070 void HeroClass::setClimbCoverY(int32_t new_y)
1071 {
1072 climb_cover_y=new_y;
1073 }
1074 34354 int32_t HeroClass::getLStep()
1075 {
1076 34354 return lstep;
1077 }
1078 2195 int32_t HeroClass::getCharging()
1079 {
1080 2195 return charging;
1081 }
1082 22788 bool HeroClass::isCharged()
1083 {
1084 22788 return spins>0;
1085 }
1086 int32_t HeroClass::getAttackClk()
1087 {
1088 return attackclk;
1089 }
1090 void HeroClass::setAttackClk(int32_t new_clk)
1091 {
1092 attackclk=new_clk;
1093 }
1094 void HeroClass::setCharging(int32_t new_charging)
1095 {
1096 charging=new_charging;
1097 }
1098 1001141078 int32_t HeroClass::getSwordClk()
1099 {
1100 1001141078 return swordclk;
1101 }
1102 980484461 int32_t HeroClass::getItemClk()
1103 {
1104 980484461 return itemclk;
1105 }
1106 void HeroClass::setSwordClk(int32_t newclk)
1107 {
1108 swordclk=newclk;
1109 verifyAWpn();
1110 }
1111 void HeroClass::setItemClk(int32_t newclk)
1112 {
1113 itemclk=newclk;
1114 }
1115 62785 zfix HeroClass::getModifiedX()
1116 {
1117 62785 zfix tempx=x;
1118
1119
4/4
✓ Branch 0 taken 13702 times.
✓ Branch 1 taken 49083 times.
✓ Branch 2 taken 11216 times.
✓ Branch 3 taken 2486 times.
62785 if(screenscrolling&&(dir==left))
1120 {
1121 2486 tempx=tempx+256;
1122 2486 }
1123
1124 62785 return tempx;
1125 }
1126
1127 62785 zfix HeroClass::getModifiedY()
1128 {
1129 62785 zfix tempy=y;
1130
1131
4/4
✓ Branch 0 taken 13702 times.
✓ Branch 1 taken 49083 times.
✓ Branch 2 taken 4351 times.
✓ Branch 3 taken 9351 times.
62785 if(screenscrolling&&(dir==up))
1132 {
1133 4351 tempy=tempy+176;
1134 4351 }
1135
1136 62785 return tempy;
1137 }
1138
1139 4902 int32_t HeroClass::getDir()
1140 {
1141 4902 return dir;
1142 }
1143 181 void HeroClass::setDir(int32_t newdir)
1144 {
1145 181 dir=newdir;
1146 181 reset_hookshot();
1147 181 }
1148 int32_t HeroClass::getHitDir()
1149 {
1150 return hitdir;
1151 }
1152 void HeroClass::setHitDir(int32_t newdir)
1153 {
1154 hitdir = newdir;
1155 }
1156 int32_t HeroClass::getClk()
1157 {
1158 return clk;
1159 }
1160 int32_t HeroClass::getPushing()
1161 {
1162 return pushing;
1163 }
1164 3978 void HeroClass::Catch()
1165 {
1166
5/6
✓ Branch 0 taken 3978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3071 times.
✓ Branch 3 taken 907 times.
✓ Branch 4 taken 1612 times.
✓ Branch 5 taken 1459 times.
3978 if(!inwallm && (action==none || action==walking))
1167 {
1168 2519 SetAttack();
1169 2519 attackclk=0;
1170 2519 attack=wCatching;
1171 2519 }
1172 3978 }
1173
1174 1830122 bool HeroClass::getClock()
1175 {
1176 1830122 return superman;
1177 }
1178 352 void HeroClass::setClock(bool state)
1179 {
1180 352 superman=state;
1181 352 }
1182 16031916 int32_t HeroClass::getAction() // Used by ZScript
1183 {
1184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16031916 times.
16031916 if(spins > 0)
1185 return isspinning;
1186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16031916 times.
16031916 else if(charging > 0)
1187 return ischarging;
1188
2/2
✓ Branch 0 taken 16016988 times.
✓ Branch 1 taken 14928 times.
16031916 else if(diveclk > 0)
1189 14928 return isdiving;
1190 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1191
1192 16016988 return action;
1193 16031916 }
1194
1195 5333249 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1196 {
1197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5333249 times.
5333249 if(spins > 0)
1198 return isspinning;
1199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5333249 times.
5333249 else if(charging > 0)
1200 return ischarging;
1201
2/2
✓ Branch 0 taken 5320819 times.
✓ Branch 1 taken 12430 times.
5333249 else if(diveclk > 0)
1202 12430 return isdiving;
1203 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1204
1205 5320819 return -1;
1206 5333249 }
1207
1208 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1209 {
1210 if(new_action==dying || new_action==won || new_action==scrolling ||
1211 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1212 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1213 return; // Can't use these actions.
1214
1215 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1216 return;
1217
1218 if(new_action==rafting)
1219 {
1220 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1221 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1222 return;
1223 }
1224
1225
1226 if(magicitem>-1 && itemsbuf[magicitem].family==itype_faroreswind)
1227 {
1228 // Using Farore's Wind
1229 if(magiccastclk<96)
1230 {
1231 // Not cast yet; cancel it
1232 magicitem=-1;
1233 magiccastclk=0;
1234 }
1235 else
1236 // Already activated; don't do anything
1237 return;
1238 }
1239
1240 if(action==inwind) // Remove from whirlwind
1241 {
1242 xofs=0;
1243 whirlwind=0;
1244 lstep=0;
1245 if ( dontdraw < 2 ) { dontdraw=0; }
1246 }
1247 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1248 {
1249 sprite* wind=0;
1250 bool foundWind=false;
1251 for(int32_t i=0; i<Ewpns.Count(); i++)
1252 {
1253 wind=Ewpns.spr(i);
1254 if(wind->id==ewWind && wind->misc==999)
1255 {
1256 foundWind=true;
1257 break;
1258 }
1259 }
1260
1261 if(foundWind)
1262 {
1263 xofs=0;
1264 if ( dontdraw < 2 ) { dontdraw=false; }
1265 wind->misc=-1;
1266 x=wind->x;
1267 y=wind->y;
1268 }
1269 }
1270
1271 //Unless compat rule is on, reset hopping clocks when writing action!
1272 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1273 {
1274 hopclk = 0;
1275 hopdir = -1;
1276 }
1277
1278 if(new_action != attacking && new_action != sideswimattacking)
1279 {
1280 attackclk=0;
1281
1282 if(attack==wHookshot)
1283 reset_hookshot();
1284 }
1285 if(new_action != isspinning && new_action != sideswimisspinning)
1286 {
1287 charging = 0;
1288 spins = 0;
1289 }
1290
1291 if(action == falling && new_action != falling)
1292 {
1293 fallclk = 0; //Stop falling;
1294 }
1295
1296 if (action == rafting && new_action != rafting)
1297 {
1298 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1299 raftwarpy = y;
1300 }
1301
1302 switch(new_action)
1303 {
1304 case isspinning:
1305 case sideswimisspinning:
1306 if(attack==wSword)
1307 {
1308 attackclk = SWORDCHARGEFRAME+1;
1309 charging = 0;
1310
1311 if(spins==0)
1312 spins = 5;
1313 }
1314 return;
1315
1316 case isdiving:
1317 if(action==swimming && diveclk==0)
1318 {
1319 int32_t flippers_id = current_item_id(itype_flippers);
1320 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1321 }
1322 return;
1323
1324 case drowning:
1325 case sidedrowning:
1326 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1327 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1328 if(!drownclk)
1329 Drown();
1330
1331 break;
1332
1333 case lavadrowning:
1334 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1335 if(!drownclk)
1336 Drown(1);
1337
1338 break;
1339
1340 case falling:
1341 if(!fallclk)
1342 {
1343 //If there is a pit under Hero, use it's combo.
1344 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1345 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1346 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1347 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1348 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1349 //Else, use a null value; triggers default pit values
1350 else fallCombo = 0;
1351 fallclk = PITFALL_FALL_FRAMES;
1352 }
1353 break;
1354
1355 case gothit:
1356 case swimhit:
1357 case sideswimhit:
1358 if(!hclk)
1359 hclk=48;
1360
1361 break;
1362
1363 case landhold1:
1364 case landhold2:
1365 case waterhold1:
1366 case waterhold2:
1367 case sidewaterhold1:
1368 case sidewaterhold2:
1369 if(!holdclk)
1370 holdclk=130;
1371
1372 attack=none;
1373 break;
1374
1375 case attacking:
1376 case sideswimattacking:
1377 attack=none;
1378 break;
1379
1380 default:
1381 break;
1382 }
1383
1384 action=new_action; FFCore.setHeroAction(new_action);
1385 }
1386
1387 void HeroClass::setHeldItem(int32_t newitem)
1388 {
1389 holditem=newitem;
1390 }
1391 int32_t HeroClass::getHeldItem()
1392 {
1393 return holditem;
1394 }
1395 2305149 bool HeroClass::isDiving()
1396 {
1397 2305149 int32_t flippers_id = current_item_id(itype_flippers);
1398
2/2
✓ Branch 0 taken 1947322 times.
✓ Branch 1 taken 357827 times.
2305149 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1399 }
1400 5209375 bool HeroClass::isSwimming()
1401 {
1402
4/6
✓ Branch 0 taken 5186913 times.
✓ Branch 1 taken 22462 times.
✓ Branch 2 taken 5186913 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5186913 times.
✗ Branch 5 not taken.
10396288 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1403
3/4
✓ Branch 0 taken 5186393 times.
✓ Branch 1 taken 520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5186393 times.
5186913 (action==waterhold1)||(action==waterhold2)||
1404 5186393 (hopclk==0xFF));
1405 }
1406
1407 357 void HeroClass::setDontDraw(byte new_dontdraw)
1408 {
1409 357 dontdraw=new_dontdraw;
1410 357 }
1411
1412 231649 byte HeroClass::getDontDraw()
1413 {
1414 231649 return dontdraw;
1415 }
1416
1417 void HeroClass::setHClk(int32_t newhclk)
1418 {
1419 hclk=newhclk;
1420 }
1421
1422 59239 int32_t HeroClass::getHClk()
1423 {
1424 59239 return hclk;
1425 }
1426
1427 828029 int32_t HeroClass::getSpecialCave()
1428 {
1429 828029 return specialcave; // used only by maps.cpp
1430 }
1431
1432 112 void HeroClass::init()
1433 {
1434 112 usecounts.clear();
1435 112 scale = 0;
1436 112 rotation = 0;
1437 112 do_animation = 1;
1438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(lift_wpn)
1439 {
1440 delete lift_wpn;
1441 lift_wpn = nullptr;
1442 }
1443 112 liftclk = 0;
1444 112 tliftclk = 0;
1445 112 liftheight = 0;
1446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1447 112 hookshot_used=false;
1448 112 hookshot_frozen=false;
1449 112 onpassivedmg=false;
1450 112 dir = up;
1451 112 damageovertimeclk = 0;
1452 112 newconveyorclk = 0;
1453 112 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1454
2/2
✓ Branch 0 taken 784 times.
✓ Branch 1 taken 112 times.
896 for(auto q = 0; q < 7; ++q)
1455 784 hooked_undercombos[q] = -1;
1456 112 shiftdir = -1;
1457 112 sideswimdir = right;
1458 112 holddir = -1;
1459 112 landswim = 0;
1460 112 sdir = up;
1461 112 ilswim=true;
1462 112 walkable=false;
1463 112 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1464 112 warp_sound = 0;
1465 112 subscr_speed = zinit.subscrSpeed;
1466 112 steprate = zinit.heroStep;
1467 112 is_warping = false;
1468 112 can_mirror_portal = true;
1469 112 coyotetime = 0;
1470
1471 112 hammer_swim_up_offset = hammeroffsets[0];
1472 112 hammer_swim_down_offset = hammeroffsets[1];
1473 112 hammer_swim_left_offset = hammeroffsets[2];
1474 112 hammer_swim_right_offset = hammeroffsets[3];
1475
1476 112 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1477
1478
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 110 times.
112 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1479 {
1480 2 x=tmpscr->warpreturnx[0];
1481 2 y=tmpscr->warpreturny[0];
1482 2 }
1483 else
1484 {
1485 110 x=tmpscr->warparrivalx;
1486 110 y=tmpscr->warparrivaly;
1487 }
1488
1489 112 z=fakez=fall=fakefall=0;
1490 112 hzsz = 12; // So that flying peahats can still hit him.
1491
1492
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 97 times.
112 if(x==0) dir=right;
1493
1494
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 111 times.
112 if(x==240) dir=left;
1495
1496
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 95 times.
112 if(y==0) dir=down;
1497
1498
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 89 times.
112 if(y==160) dir=up;
1499
1500 112 lstep=0;
1501 112 skipstep=0;
1502 112 autostep=false;
1503 112 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1504 112 attack=wNone;
1505 112 attackid=-1;
1506 112 action=none; FFCore.setHeroAction(none); tempaction=none;
1507 112 xofs=0;
1508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1509 112 cs=6;
1510 112 pushing=fairyclk=0;
1511 112 id=0;
1512 112 inlikelike=0;
1513 112 superman=inwallm=false;
1514 112 scriptcoldet=1;
1515 112 blowcnt=whirlwind=specialcave=0;
1516 112 hopclk=diveclk=fallclk=0;
1517 112 fallCombo = 0;
1518 112 pit_pulldir = -1;
1519 112 hopdir=-1;
1520 112 conveyor_flags=0;
1521 112 drunkclk=0;
1522 112 lstunclock = 0;
1523 112 is_conveyor_stunned=0;
1524 112 drawstyle=3;
1525 112 ffwarp = false;
1526 112 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1527 112 stepnext=stepsecret=-1;
1528 112 ffpit = false;
1529 112 respawn_x=x;
1530 112 respawn_y=y;
1531 112 respawn_dmap=currdmap;
1532 112 respawn_scr=currscr;
1533 112 falling_oldy = y;
1534 112 magiccastclk=0;
1535 112 magicitem = nayruitem = -1;
1536 112 last_lens_id = 0; //Should be -1 (-Z)
1537 112 last_savepoint_id = 0;
1538 112 misc_internal_hero_flags = 0;
1539 112 last_cane_of_byrna_item_id = -1;
1540 112 on_sideview_ladder = false;
1541 112 switchblock_z = 0;
1542 112 switchblock_offset = false;
1543 112 extra_jump_count = 0;
1544 112 hoverflags = 0;
1545 112 lbunnyclock = 0;
1546
1547
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 112 times.
3696 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1548
1549 112 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1550 112 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1551
1552 112 shield_active = false;
1553 112 shield_forcedir = -1;
1554 112 active_shield_id = -1;
1555
1556 //2.6
1557 112 preventsubscreenfalling = false; //-Z
1558 112 walkspeed = 0; //not used, yet. -Z
1559
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 112 times.
1904 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1560
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 112 times.
1904 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1561
2/2
✓ Branch 0 taken 16352 times.
✓ Branch 1 taken 112 times.
16464 for ( int32_t q = 0; q < wMax; q++ )
1562 {
1563 16352 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1564 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1565 16352 }
1566 //Run script!
1567
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
112 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1568 {
1569 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1570 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1571 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1572 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1573 //are properly set by the engine.
1574 }
1575 112 FFCore.nostepforward = 0;
1576 112 }
1577
1578 2756895 void HeroClass::draw_under(BITMAP* dest)
1579 {
1580 2756895 int32_t c_raft=current_item_id(itype_raft);
1581 2756895 int32_t c_ladder=current_item_id(itype_ladder);
1582
1583
3/4
✓ Branch 0 taken 20431 times.
✓ Branch 1 taken 2736464 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20431 times.
2756895 if(action==rafting && c_raft >-1)
1584 {
1585
4/4
✓ Branch 0 taken 15765 times.
✓ Branch 1 taken 4666 times.
✓ Branch 2 taken 12928 times.
✓ Branch 3 taken 7503 times.
20431 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1586 {
1587 15006 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1588 7503 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1589 7503 }
1590 else
1591 {
1592 25856 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1593 12928 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1594 }
1595 20431 }
1596
1597
3/4
✓ Branch 0 taken 48051 times.
✓ Branch 1 taken 2708844 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48051 times.
2756895 if(ladderx+laddery && c_ladder >-1)
1598 {
1599
4/4
✓ Branch 0 taken 21760 times.
✓ Branch 1 taken 26291 times.
✓ Branch 2 taken 5649 times.
✓ Branch 3 taken 16111 times.
48051 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1600 {
1601 11298 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1602 5649 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1603 5649 }
1604 else
1605 {
1606 84804 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1607 42402 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1608 }
1609 48051 }
1610 2756895 }
1611
1612 120 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1613 {
1614 120 int32_t tempy=yofs;
1615 120 yofs+=8;
1616 120 shadowtile = wpnsbuf[spr_shadow].tile;
1617 120 sprite::drawshadow(dest,translucent);
1618 120 yofs=tempy;
1619 120 }
1620
1621 // The Stone of Agony reacts to these flags.
1622 bool HeroClass::agonyflag(int32_t flag)
1623 {
1624 switch(flag)
1625 {
1626 case mfWHISTLE:
1627 case mfBCANDLE:
1628 case mfARROW:
1629 case mfBOMB:
1630 case mfSBOMB:
1631 case mfBRANG:
1632 case mfMBRANG:
1633 case mfFBRANG:
1634 case mfSARROW:
1635 case mfGARROW:
1636 case mfRCANDLE:
1637 case mfWANDFIRE:
1638 case mfDINSFIRE:
1639 case mfWANDMAGIC:
1640 case mfREFMAGIC:
1641 case mfREFFIREBALL:
1642 case mfSWORD:
1643 case mfWSWORD:
1644 case mfMSWORD:
1645 case mfXSWORD:
1646 case mfSWORDBEAM:
1647 case mfWSWORDBEAM:
1648 case mfMSWORDBEAM:
1649 case mfXSWORDBEAM:
1650 case mfHOOKSHOT:
1651 case mfWAND:
1652 case mfHAMMER:
1653 case mfSTRIKE:
1654 return true;
1655 }
1656
1657 return false;
1658 }
1659
1660
1661 // Find the attack power of the current melee weapon.
1662 // The Whimsical Ring is applied on a target-by-target basis.
1663 243848 int32_t HeroClass::weaponattackpower(int32_t itid)
1664 {
1665
1/2
✓ Branch 0 taken 243848 times.
✗ Branch 1 not taken.
243848 if(itid < 0)
1666 {
1667 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1668 : attack==wWand ? itype_wand
1669 : attack==wHammer ? itype_hammer
1670 : itype_sword);
1671 }
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243848 times.
243848 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1673
1674 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1675
1/6
✓ Branch 0 taken 243848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
243848 power *= (spins>0 ? itemsbuf[current_item_id(attack==wHammer ? itype_quakescroll : (spins>5 || current_item_id(itype_spinscroll) < 0) ? itype_spinscroll2 : itype_spinscroll)].power : 1);
1676 243848 return power;
1677 }
1678
1679 #define NET_CLK_TOTAL 24
1680 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1681 // Must only be called once per frame!
1682 void HeroClass::positionNet(weapon *w, int32_t itemid)
1683 {
1684 itemid = vbound(itemid, 0, MAXITEMS-1);
1685 int32_t t = w->o_tile,
1686 wx = 1, wy = 1;
1687
1688 //Invert positioning clock if right-handed animation
1689 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1690 if(clock >= NET_CLK_TOTAL)
1691 w->dead = 0;
1692 int32_t tiledir = dir;
1693 switch(dir)
1694 {
1695 case up:
1696 {
1697 if(clock < NET_DIR_INC) tiledir = l_up;
1698 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1699 break;
1700 }
1701 case down:
1702 {
1703 if(clock < NET_DIR_INC) tiledir = r_down;
1704 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1705 break;
1706 }
1707 case left:
1708 {
1709 if(clock < NET_DIR_INC) tiledir = l_down;
1710 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1711 break;
1712 }
1713 case right:
1714 {
1715 if(clock < NET_DIR_INC) tiledir = r_up;
1716 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1717 break;
1718 }
1719 }
1720 int32_t offs = 0;
1721 if(tiledir > right)
1722 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1723 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1724 //One of 8 positions
1725 switch(tiledir)
1726 {
1727 case up:
1728 {
1729 wx = 6*offs;
1730 wy = -14;
1731 break;
1732 }
1733 case r_up:
1734 {
1735 wx = (offs ? 10 : 14);
1736 wy = (offs ? -12 : -10);
1737 break;
1738 }
1739 case right:
1740 {
1741 wx = 14;
1742 wy = 6*offs;
1743 break;
1744 }
1745 case r_down:
1746 {
1747 wx = (offs ? 14 : 10);
1748 wy = (offs ? 10 : 12);
1749 break;
1750 }
1751 case down:
1752 {
1753 wx = -6*offs;
1754 wy = 14;
1755 break;
1756 }
1757 case l_down:
1758 {
1759 wx = (offs ? -10 : -14);
1760 wy = (offs ? 12 : 10);
1761 break;
1762 }
1763 case left:
1764 {
1765 wx = -14;
1766 wy = -6*offs;
1767 break;
1768 }
1769 case l_up:
1770 {
1771 wx = (offs ? -14 : -10);
1772 wy = (offs ? -10 : -12);
1773 break;
1774 }
1775 }
1776
1777 w->x = x+wx;
1778 w->y = y+wy-(54-(yofs))-fakez;
1779 w->z = (z+zofs);
1780 w->fakez = fakez;
1781 w->tile = t+tiledir;
1782 w->power = 0;
1783 w->dir = dir;
1784 w->doAutoRotate(true);
1785 }
1786 224592 void HeroClass::positionSword(weapon *w, int32_t itemid)
1787 {
1788 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1789 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1790 224592 itemid=vbound(itemid, 0, MAXITEMS-1);
1791 // Place a sword weapon at the right spot.
1792 224592 int32_t wy=1;
1793 224592 int32_t wx=1;
1794 224592 int32_t f=0,t,cs2;
1795
1796 224592 t = w->o_tile;
1797 224592 cs2 = w->o_cset;
1798 224592 slashxofs=0;
1799 224592 slashyofs=0;
1800
1801
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 48447 times.
✓ Branch 2 taken 49931 times.
✓ Branch 3 taken 63786 times.
✓ Branch 4 taken 62428 times.
224592 switch(dir)
1802 {
1803 case up:
1804 48447 wx=-1;
1805 48447 wy=-12;
1806
1807
6/8
✓ Branch 0 taken 2745 times.
✓ Branch 1 taken 45702 times.
✓ Branch 2 taken 2735 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2735 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2735 times.
48447 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1808 {
1809
2/2
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 951 times.
2735 if(attackclk>10) //extended stab
1810 {
1811 951 slashyofs-=3;
1812 951 wy-=2;
1813 951 }
1814
1815
2/2
✓ Branch 0 taken 2499 times.
✓ Branch 1 taken 236 times.
2735 if(attackclk>=14) //retracting stab
1816 {
1817 236 slashyofs+=3;
1818 236 wy+=2;
1819 236 }
1820 2735 }
1821 else
1822 {
1823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45712 times.
45712 if(attackclk==SWORDCHARGEFRAME)
1824 {
1825 wy+=4;
1826 }
1827
2/2
✓ Branch 0 taken 4464 times.
✓ Branch 1 taken 41248 times.
45712 else if(attackclk==13)
1828 {
1829 4464 wy+=4;
1830 4464 }
1831
2/2
✓ Branch 0 taken 36798 times.
✓ Branch 1 taken 4450 times.
41248 else if(attackclk==14)
1832 {
1833 4450 wy+=8;
1834 4450 }
1835 }
1836
1837 48447 break;
1838
1839 case down:
1840 49931 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1841 49931 wy=11;
1842
1843
6/8
✓ Branch 0 taken 3771 times.
✓ Branch 1 taken 46160 times.
✓ Branch 2 taken 3528 times.
✓ Branch 3 taken 243 times.
✓ Branch 4 taken 3528 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3528 times.
49931 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1844 {
1845
2/2
✓ Branch 0 taken 2282 times.
✓ Branch 1 taken 1246 times.
3528 if(attackclk>10) //extended stab
1846 {
1847 1246 slashyofs+=3;
1848 1246 wy+=2;
1849 1246 }
1850
1851
2/2
✓ Branch 0 taken 3221 times.
✓ Branch 1 taken 307 times.
3528 if(attackclk>=14) //retracting stab
1852 {
1853 307 slashyofs-=3;
1854 307 wy-=2;
1855 307 }
1856 3528 }
1857 else
1858 {
1859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46403 times.
46403 if(attackclk==SWORDCHARGEFRAME)
1860 {
1861 wy-=2;
1862 }
1863
2/2
✓ Branch 0 taken 4607 times.
✓ Branch 1 taken 41796 times.
46403 else if(attackclk==13)
1864 {
1865 4607 wy-=4;
1866 4607 }
1867
2/2
✓ Branch 0 taken 37200 times.
✓ Branch 1 taken 4596 times.
41796 else if(attackclk==14)
1868 {
1869 4596 wy-=8;
1870 4596 }
1871 }
1872
1873 49931 break;
1874
1875 case left:
1876 63786 f=1;
1877 63786 wx=-11;
1878 63786 ++t;
1879
1880
6/8
✓ Branch 0 taken 4077 times.
✓ Branch 1 taken 59709 times.
✓ Branch 2 taken 3880 times.
✓ Branch 3 taken 197 times.
✓ Branch 4 taken 3880 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3880 times.
63786 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1881 {
1882
2/2
✓ Branch 0 taken 2506 times.
✓ Branch 1 taken 1374 times.
3880 if(attackclk>10) //extended stab
1883 {
1884 1374 slashxofs-=4;
1885 1374 wx-=7;
1886 1374 }
1887
1888
2/2
✓ Branch 0 taken 3541 times.
✓ Branch 1 taken 339 times.
3880 if(attackclk>=14) //retracting stab
1889 {
1890 339 slashxofs+=3;
1891 339 wx+=7;
1892 339 }
1893 3880 }
1894 else
1895 {
1896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59906 times.
59906 if(attackclk==SWORDCHARGEFRAME)
1897 {
1898 wx+=2;
1899 }
1900
2/2
✓ Branch 0 taken 5965 times.
✓ Branch 1 taken 53941 times.
59906 else if(attackclk==13)
1901 {
1902 5965 wx+=4;
1903 5965 }
1904
2/2
✓ Branch 0 taken 47992 times.
✓ Branch 1 taken 5949 times.
53941 else if(attackclk==14)
1905 {
1906 5949 wx+=8;
1907 5949 }
1908 }
1909
1910 63786 break;
1911
1912 case right:
1913 62428 wx=11;
1914 62428 ++t;
1915
1916
6/8
✓ Branch 0 taken 3525 times.
✓ Branch 1 taken 58903 times.
✓ Branch 2 taken 2845 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 2845 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2845 times.
✗ Branch 7 not taken.
62428 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1917 {
1918
2/2
✓ Branch 0 taken 1841 times.
✓ Branch 1 taken 1004 times.
2845 if(attackclk>10) //extended stab
1919 {
1920 1004 slashxofs+=4;
1921 1004 wx+=7;
1922 1004 }
1923
1924
2/2
✓ Branch 0 taken 2595 times.
✓ Branch 1 taken 250 times.
2845 if(attackclk>=14) //retracting stab
1925 {
1926 250 slashxofs-=3;
1927 250 wx-=7;
1928 250 }
1929 2845 }
1930 else
1931 {
1932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59583 times.
59583 if(attackclk==SWORDCHARGEFRAME)
1933 {
1934 wx-=2;
1935 }
1936
2/2
✓ Branch 0 taken 5908 times.
✓ Branch 1 taken 53675 times.
59583 else if(attackclk==13)
1937 {
1938 5908 wx-=4;
1939 5908 }
1940
2/2
✓ Branch 0 taken 47778 times.
✓ Branch 1 taken 5897 times.
53675 else if(attackclk==14)
1941 {
1942 5897 wx-=8;
1943 5897 }
1944 }
1945
1946 62428 break;
1947 }
1948
1949
6/6
✓ Branch 0 taken 14118 times.
✓ Branch 1 taken 210474 times.
✓ Branch 2 taken 12988 times.
✓ Branch 3 taken 1130 times.
✓ Branch 4 taken 4575 times.
✓ Branch 5 taken 8413 times.
224592 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1950 {
1951 8413 int32_t wpn2=itemsbuf[itemid].wpn2;
1952 8413 wpn2=vbound(wpn2, 0, MAXWPNS);
1953
1954 //slashing tiles
1955
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1784 times.
✓ Branch 2 taken 2282 times.
✓ Branch 3 taken 2506 times.
✓ Branch 4 taken 1841 times.
8413 switch(dir)
1956 {
1957 case up:
1958 1784 wx=15;
1959 1784 wy=-3;
1960 1784 ++t;
1961 1784 f=0; //starts pointing right
1962
1963
2/2
✓ Branch 0 taken 791 times.
✓ Branch 1 taken 993 times.
1784 if(attackclk>=7)
1964 {
1965 993 wy-=9;
1966 993 wx-=3;
1967 993 t = wpnsbuf[wpn2].tile;
1968 993 cs2 = wpnsbuf[wpn2].csets&15;
1969 993 f=0;
1970 993 }
1971
1972 1784 break;
1973
1974 case down:
1975 2282 wx=-13;
1976 2282 wy=-1;
1977 2282 ++t;
1978 2282 f=1; //starts pointing left
1979
1980
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1288 times.
2282 if(attackclk>=7)
1981 {
1982 1288 wy+=15;
1983 1288 wx+=2;
1984 1288 t = wpnsbuf[wpn2].tile;
1985 1288 cs2 = wpnsbuf[wpn2].csets&15;
1986 1288 ++t;
1987 1288 f=0;
1988 1288 }
1989
1990 2282 break;
1991
1992 case left:
1993 2506 wx=3;
1994 2506 wy=-15;
1995 2506 --t;
1996 2506 f=0; //starts pointing up
1997
1998
2/2
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 1413 times.
2506 if(attackclk>=7)
1999 {
2000 1413 wx-=15;
2001 1413 wy+=3;
2002 1413 slashxofs-=1;
2003 1413 t = wpnsbuf[wpn2].tile;
2004 1413 cs2 = wpnsbuf[wpn2].csets&15;
2005 1413 t+=2;
2006 1413 f=0;
2007 1413 }
2008
2009 2506 break;
2010
2011 case right:
2012 1841 --t;
2013
2014
2/4
✓ Branch 0 taken 1841 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1841 times.
1841 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2015 {
2016 wx=1;
2017 wy=13;
2018 f=2;
2019 }
2020 else
2021 {
2022 1841 wx=3;
2023 1841 wy=-15;
2024 1841 f=0;
2025 }
2026
2027
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 1031 times.
1841 if(attackclk>=7)
2028 {
2029 1031 wx+=15;
2030 1031 slashxofs+=1;
2031 1031 t = wpnsbuf[wpn2].tile;
2032 1031 cs2 = wpnsbuf[wpn2].csets&15;
2033
2034
2/4
✓ Branch 0 taken 1031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1031 times.
1031 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2035 {
2036 wx-=1;
2037 wy-=2;
2038 }
2039 else
2040 {
2041 1031 t+=3;
2042 1031 f=0;
2043 1031 wy+=3;
2044 }
2045 1031 }
2046
2047 1841 break;
2048 }
2049 8413 }
2050
2051 224592 int32_t itemid2 = current_item_id(itype_chargering);
2052
2053
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224592 times.
✓ Branch 2 taken 224592 times.
✗ Branch 3 not taken.
224592 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2054 {
2055 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2056 }
2057
2058 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2059 {
2060 wy+=2;
2061 }*/
2062 224592 w->x = x+wx;
2063 224592 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2064 224592 w->z = (z+zofs);
2065 224592 w->tile = t;
2066 224592 w->flip = f;
2067 224592 w->power = weaponattackpower(itemid);
2068 224592 w->dir = dir;
2069 224592 w->doAutoRotate(true);
2070 224592 }
2071
2072 2774152 void HeroClass::draw(BITMAP* dest)
2073 {
2074 /*{
2075 char buf[36];
2076 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2077 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2078 }*/
2079 int32_t oxofs, oyofs;
2080 2774152 bool shieldModify = false;
2081
2/2
✓ Branch 0 taken 2765719 times.
✓ Branch 1 taken 8433 times.
2774152 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2082
2083
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2773672 times.
2774152 if(action==dying)
2084 {
2085
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 112 times.
480 if(!invisible)
2086 {
2087
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2088 112 sprite::draw(dest);
2089 112 }
2090 480 return;
2091 }
2092
2093 2773672 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2094
2095 2773672 oxofs=xofs;
2096 2773672 oyofs=yofs;
2097
2098
2/2
✓ Branch 0 taken 8065 times.
✓ Branch 1 taken 2765607 times.
2773672 if(!invisible)
2099
6/6
✓ Branch 0 taken 2754890 times.
✓ Branch 1 taken 10717 times.
✓ Branch 2 taken 1997631 times.
✓ Branch 3 taken 757259 times.
✓ Branch 4 taken 106372 times.
✓ Branch 5 taken 1891259 times.
2765607 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2100
2101 // Stone of Agony
2102 2773672 bool agony=false;
2103 2773672 int32_t agonyid = current_item_id(itype_agony);
2104
2105
2/2
✓ Branch 0 taken 8065 times.
✓ Branch 1 taken 2765607 times.
2773672 if(invisible)
2106 8065 goto attack;
2107
2108
1/2
✓ Branch 0 taken 2765607 times.
✗ Branch 1 not taken.
2765607 if(agonyid>-1)
2109 {
2110 int32_t power=itemsbuf[agonyid].power;
2111 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2112 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2113 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2114 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2115
2116 for(int32_t x=left; x<right; x+=16)
2117 {
2118 for(int32_t y=top; y<bottom; y+=16)
2119 {
2120 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2121 {
2122 agony=true;
2123 x=right; // Break out of outer loop
2124 break;
2125 }
2126 }
2127 }
2128 }
2129
2130 2765607 cs = 6;
2131
1/2
✓ Branch 0 taken 2765607 times.
✗ Branch 1 not taken.
2765607 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2132
2/2
✓ Branch 0 taken 708549 times.
✓ Branch 1 taken 2057058 times.
4822665 if(!get_bit(quest_rules,qr_HEROFLICKER))
2133 {
2134
3/4
✓ Branch 0 taken 47392 times.
✓ Branch 1 taken 2009666 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47392 times.
2057058 if(superman && getCanFlicker())
2135 {
2136 47392 cs += (((~frame)>>1)&3);
2137 47392 }
2138
4/6
✓ Branch 0 taken 96801 times.
✓ Branch 1 taken 1912865 times.
✓ Branch 2 taken 96801 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 96801 times.
2009666 else if(hclk&&(NayrusLoveShieldClk<=0) && getCanFlicker())
2139 {
2140 96801 cs += ((hclk>>1)&3);
2141 96801 }
2142 2057058 }
2143
2144 attack:
2145
2146
5/6
✓ Branch 0 taken 2379163 times.
✓ Branch 1 taken 394509 times.
✓ Branch 2 taken 2376644 times.
✓ Branch 3 taken 2519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2376644 times.
2773672 if(attackclk || (action==attacking||action==sideswimattacking))
2147 {
2148 /* Spaghetti code constants!
2149 * - Hero.attack contains a weapon type...
2150 * - which must be converted to an itype...
2151 * - which must be converted to an item ID...
2152 * - which is used to acquire a wpn ID! Aack!
2153 */
2154
6/8
✓ Branch 0 taken 6471 times.
✓ Branch 1 taken 390557 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 390557 times.
✓ Branch 4 taken 8554 times.
✓ Branch 5 taken 382003 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 382003 times.
397028 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2155
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 397028 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
397028 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2156 397028 itemid=vbound(itemid, 0, MAXITEMS-1);
2157 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2158
7/8
✓ Branch 0 taken 126304 times.
✓ Branch 1 taken 270724 times.
✓ Branch 2 taken 126304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89749 times.
✓ Branch 5 taken 36555 times.
✓ Branch 6 taken 4974 times.
✓ Branch 7 taken 84775 times.
397028 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2159 {
2160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275698 times.
275698 if(attack == wBugNet)
2161 {
2162 weapon *w=NULL;
2163 bool found = false;
2164 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2165 {
2166 w = (weapon*)Lwpns.spr(q);
2167 if(w->id == wBugNet)
2168 {
2169 found = true;
2170 break;
2171 }
2172 }
2173 if(!found)
2174 {
2175 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2176
2177 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2178 }
2179 positionNet(w, itemid);
2180 }
2181
8/8
✓ Branch 0 taken 53499 times.
✓ Branch 1 taken 222199 times.
✓ Branch 2 taken 47389 times.
✓ Branch 3 taken 6110 times.
✓ Branch 4 taken 42962 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 47389 times.
✓ Branch 7 taken 228309 times.
275698 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2182 {
2183 // Create a sword weapon at the right spot.
2184 228309 weapon *w=NULL;
2185 228309 bool found = false;
2186
2187 // Look for pre-existing sword
2188
2/2
✓ Branch 0 taken 22789 times.
✓ Branch 1 taken 253532 times.
276321 for(int32_t i=0; i<Lwpns.Count(); i++)
2189 {
2190 253532 w = (weapon*)Lwpns.spr(i);
2191
2192
2/2
✓ Branch 0 taken 48012 times.
✓ Branch 1 taken 205520 times.
253532 if(w->id == (attack==wSword ? wSword : wWand))
2193 {
2194 205520 found = true;
2195 205520 break;
2196 }
2197 48012 }
2198
2199
2/2
✓ Branch 0 taken 205520 times.
✓ Branch 1 taken 22789 times.
228309 if(!found) // Create one if sword nonexistant
2200 {
2201
5/10
✓ Branch 0 taken 22789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22789 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 22789 times.
✗ Branch 9 not taken.
22789 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2202 22789 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2203
2204 22789 positionSword(w,itemid);
2205
2206 // Stone of Agony
2207
1/2
✓ Branch 0 taken 22789 times.
✗ Branch 1 not taken.
22789 if(agony)
2208 {
2209 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2210 }
2211 22789 }
2212
2213 // These are set by positionSword(), above or in checkstab()
2214 228309 yofs += slashyofs;
2215 228309 xofs += slashxofs;
2216 228309 slashyofs = slashxofs = 0;
2217 228309 }
2218 275698 }
2219
2220 397028 if(attackclk<7
2221
4/4
✓ Branch 0 taken 211686 times.
✓ Branch 1 taken 185342 times.
✓ Branch 2 taken 173148 times.
✓ Branch 3 taken 38538 times.
397028 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2222
4/6
✓ Branch 0 taken 40614 times.
✓ Branch 1 taken 132534 times.
✓ Branch 2 taken 40614 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 40614 times.
173148 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40614 times.
40614 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2224
4/4
✓ Branch 0 taken 74264 times.
✓ Branch 1 taken 4888 times.
✓ Branch 2 taken 70859 times.
✓ Branch 3 taken 3405 times.
79152 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2225
3/4
✓ Branch 0 taken 6297 times.
✓ Branch 1 taken 72855 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72855 times.
79152 || (attack==wHammer && attackclk<=30)
2226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72855 times.
72855 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2227 {
2228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324173 times.
324173 if(!invisible)
2229 {
2230 324173 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2231
2/4
✓ Branch 0 taken 324173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 324173 times.
✗ Branch 3 not taken.
324173 if (FIXED_Z3_ANIMATION)
2232 {
2233 if (attackclk >= 2) tile += (extend==2?2:1);
2234 if (attackclk >= 13) tile += (extend==2?2:1);
2235 }
2236
2237
13/18
✓ Branch 0 taken 18997 times.
✓ Branch 1 taken 305176 times.
✓ Branch 2 taken 2293 times.
✓ Branch 3 taken 16704 times.
✓ Branch 4 taken 937 times.
✓ Branch 5 taken 1356 times.
✓ Branch 6 taken 937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16704 times.
✓ Branch 9 taken 2293 times.
✓ Branch 10 taken 9300 times.
✓ Branch 11 taken 7404 times.
✓ Branch 12 taken 9300 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 9300 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
324173 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2238 {
2239 7404 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2240
2/4
✓ Branch 0 taken 7404 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7404 times.
✗ Branch 3 not taken.
7404 if (FIXED_Z3_ANIMATION)
2241 {
2242 if (attackclk >= 7) tile += (extend==2?2:1);
2243 if (attackclk >= 11) tile += (extend==2?2:1);
2244 if (attackclk >= 14) tile += (extend==2?2:1);
2245 }
2246 7404 }
2247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 324173 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
324173 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2248 {
2249 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2250 {
2251 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2252 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2253 }
2254 else
2255 {
2256 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2257 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2258 }
2259 }
2260
2261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 324173 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
324173 if((attack==wHammer) && (attackclk<13))
2262 {
2263 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2264 if (FIXED_Z3_ANIMATION)
2265 {
2266 if (attackclk >= 14) tile += (extend==2?2:1);
2267 if (attackclk >= 16) tile += (extend==2?2:1);
2268 }
2269 }
2270
2271
1/2
✓ Branch 0 taken 324173 times.
✗ Branch 1 not taken.
324173 if(useltm)
2272 {
2273 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2274 }
2275
2276 // Stone of Agony
2277
1/2
✓ Branch 0 taken 324173 times.
✗ Branch 1 not taken.
324173 if(agony)
2278 {
2279 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2280 }
2281
2282 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2283
2284 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2285
6/6
✓ Branch 0 taken 93327 times.
✓ Branch 1 taken 230846 times.
✓ Branch 2 taken 91473 times.
✓ Branch 3 taken 1854 times.
✓ Branch 4 taken 7789 times.
✓ Branch 5 taken 85538 times.
324173 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2286 {
2287 316384 masked_draw(dest);
2288 316384 }
2289
2290 //Prevent flickering -Z
2291
1/2
✓ Branch 0 taken 324173 times.
✗ Branch 1 not taken.
324173 if (!getCanFlicker()) masked_draw(dest);
2292 324173 }
2293
2294
1/2
✓ Branch 0 taken 324173 times.
✗ Branch 1 not taken.
324173 if(attack!=wHammer)
2295 {
2296 324173 xofs=oxofs;
2297 324173 yofs=oyofs;
2298 324173 return;
2299 }
2300 }
2301
2302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72855 times.
72855 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2303 {
2304 int32_t wy=1;
2305 int32_t wx=1;
2306 int32_t f=0,t,cs2;
2307 weapon *w=NULL;
2308 bool found = false;
2309
2310 for(int32_t i=0; i<Lwpns.Count(); i++)
2311 {
2312 w = (weapon*)Lwpns.spr(i);
2313
2314 if(w->id == wHammer)
2315 {
2316 found = true;
2317 break;
2318 }
2319 }
2320
2321 if(!found)
2322 {
2323 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2324 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2325 found = true;
2326 }
2327
2328 t = w->o_tile;
2329 cs2 = w->o_cset;
2330
2331 switch(dir)
2332 {
2333 case up:
2334 wx=-1;
2335 wy=-15;
2336 if (IsSideSwim())wy+=hammer_swim_up_offset;
2337
2338 if(attackclk>=13)
2339 {
2340 wx-=1;
2341 wy+=1;
2342 ++t;
2343 }
2344
2345 if(attackclk>=15)
2346 {
2347 if (IsSideSwim())wy-=hammer_swim_up_offset;
2348 ++t;
2349 }
2350
2351 break;
2352
2353 case down:
2354 wx=3;
2355 wy=-14;
2356 if (IsSideSwim())wy+=hammer_swim_down_offset;
2357 t+=3;
2358
2359 if(attackclk>=13)
2360 {
2361 wy+=16;
2362 ++t;
2363 }
2364
2365 if(attackclk>=15)
2366 {
2367 wx-=1;
2368 wy+=12;
2369 if (IsSideSwim())wy-=hammer_swim_down_offset;
2370 ++t;
2371 }
2372
2373 break;
2374
2375 case left:
2376 wx=0;
2377 wy=-14;
2378 if (IsSideSwim())wy+=hammer_swim_left_offset;
2379 t+=6;
2380 f=1;
2381
2382 if(attackclk>=13)
2383 {
2384 wx-=7;
2385 wy+=8;
2386 ++t;
2387 }
2388
2389 if(attackclk>=15)
2390 {
2391 wx-=8;
2392 wy+=8;
2393 if (IsSideSwim())wy-=hammer_swim_left_offset;
2394 ++t;
2395 }
2396
2397 break;
2398
2399 case right:
2400 wx=0;
2401 wy=-14;
2402 if (IsSideSwim())wy+=hammer_swim_right_offset;
2403 t+=6;
2404
2405 if(attackclk>=13)
2406 {
2407 wx+=7;
2408 wy+=8;
2409 ++t;
2410 }
2411
2412 if(attackclk>=15)
2413 {
2414 wx+=8;
2415 wy+=8;
2416 if (IsSideSwim())wy-=hammer_swim_right_offset;
2417 ++t;
2418 }
2419
2420 break;
2421 }
2422
2423 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2424 {
2425 wy+=2;
2426 }
2427
2428 // Stone of Agony
2429 if(agony)
2430 {
2431 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2432 }
2433
2434 w->x = x+wx;
2435 w->y = y+wy-(54-yofs)-fakez;
2436 w->z = (z+zofs);
2437 w->tile = t;
2438 w->flip = f;
2439 w->hxsz=20;
2440 w->hysz=20;
2441
2442 if(dir>down)
2443 {
2444 w->hysz-=6;
2445 }
2446 else
2447 {
2448 w->hxsz-=6;
2449 w->hyofs=4;
2450 }
2451
2452 w->power = weaponattackpower(itemid);
2453
2454 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2455 {
2456 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2457 }
2458
2459 xofs=oxofs;
2460 yofs=oyofs;
2461 return;
2462 }
2463 72855 }
2464
2/4
✓ Branch 0 taken 2376644 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2376644 times.
2376644 else if(!charging && !spins) // remove the sword
2465 {
2466
2/2
✓ Branch 0 taken 712779 times.
✓ Branch 1 taken 2376644 times.
3089423 for(int32_t i=0; i<Lwpns.Count(); i++)
2467 {
2468 712779 weapon *w = (weapon*)Lwpns.spr(i);
2469
2470
3/6
✓ Branch 0 taken 712779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 712779 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 712779 times.
712779 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2471 w->dead=1;
2472 712779 }
2473 2376644 }
2474
2475
2/2
✓ Branch 0 taken 8065 times.
✓ Branch 1 taken 2441434 times.
2449499 if(invisible)
2476 {
2477 8065 xofs=oxofs;
2478 8065 yofs=oyofs;
2479 8065 return;
2480 }
2481
2482
2/4
✓ Branch 0 taken 2441434 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2441434 times.
2441434 if(action != casting && action != sideswimcasting)
2483 {
2484 // Keep this consistent with checkspecial2, line 7800-ish...
2485
6/6
✓ Branch 0 taken 56741 times.
✓ Branch 1 taken 2384693 times.
✓ Branch 2 taken 51809 times.
✓ Branch 3 taken 4932 times.
✓ Branch 4 taken 4805 times.
✓ Branch 5 taken 47004 times.
2441434 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2486
2487 2441434 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2488 2441434 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2489 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2490
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2430717 times.
✓ Branch 3 taken 10717 times.
2441434 switch(zinit.heroAnimationStyle)
2491 {
2492 case las_original: //normal
2493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2430717 times.
2430717 if(action==drowning)
2494 {
2495 if(inwater)
2496 {
2497 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2498 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2499 }
2500 else
2501 {
2502 xofs=oxofs;
2503 yofs=oyofs;
2504 return;
2505 }
2506 }
2507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2430717 times.
2430717 else if(action==lavadrowning)
2508 {
2509 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2510 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2511 }
2512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2430717 times.
2430717 else if(action==sidedrowning)
2513 {
2514 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2515 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2516 }
2517
2/4
✓ Branch 0 taken 2430717 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2430717 times.
2430717 else if (action == sideswimming || action == sideswimhit)
2518 {
2519 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2520
2521 if(lstep>=6)
2522 {
2523 if(dir==up)
2524 {
2525 if ( script_hero_sprite <= 0 ) ++flip;
2526 }
2527 else
2528 {
2529 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2530 }
2531 }
2532 }
2533
5/6
✓ Branch 0 taken 2417668 times.
✓ Branch 1 taken 13049 times.
✓ Branch 2 taken 2417628 times.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2417628 times.
2430717 else if(action==swimming || action==swimhit || hopclk==0xFF)
2534 {
2535 13089 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2536
2537
2/2
✓ Branch 0 taken 6561 times.
✓ Branch 1 taken 6528 times.
13089 if(lstep>=6)
2538 {
2539
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 5950 times.
6528 if(dir==up)
2540 {
2541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if ( script_hero_sprite <= 0 ) ++flip;
2542 578 }
2543 else
2544 {
2545
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5950 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5950 times.
5950 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2546 }
2547 6528 }
2548
2549
2/2
✓ Branch 0 taken 11486 times.
✓ Branch 1 taken 1603 times.
13089 if(isDiving())
2550 {
2551 1603 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1603 times.
1603 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2553 1603 }
2554 13089 }
2555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2417628 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2417628 else if(charging > 0 && attack != wHammer)
2556 {
2557 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2558
2559 if(lstep>=6)
2560 {
2561 if(dir==up)
2562 {
2563 if ( script_hero_sprite <= 0 ) ++flip;
2564 }
2565 else
2566 {
2567 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2568 }
2569 }
2570 }
2571
3/12
✓ Branch 0 taken 2417628 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2417628 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2417628 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
2417628 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2572 {
2573 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2574 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2575 }
2576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2417628 times.
2417628 else if(fallclk>0)
2577 {
2578 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2579 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2580 }
2581
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2417628 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2417628 else if(!noliftspr&&action==lifting&&isLifting())
2582 {
2583 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2584 if(script_hero_sprite <= 0)
2585 {
2586 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2587 auto speed = tliftclk/frames;
2588 if (speed < 1) speed = 1;
2589 auto curframe = (tliftclk - liftclk) / speed;
2590 if (!tliftclk) curframe = frames - 1;
2591 if(unsigned(curframe) < frames)
2592 tile += curframe * (extend == 2 ? 2 : 1);
2593 }
2594 }
2595 else
2596 {
2597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2417628 times.
2417628 if(IsSideSwim())
2598 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2599
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2417628 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2417628 else if(!noliftspr&&isLifting())
2600 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2601 2417628 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2602
2603
2/2
✓ Branch 0 taken 1781224 times.
✓ Branch 1 taken 636404 times.
2417628 if(dir>up)
2604 {
2605 1781224 useltm=true;
2606 1781224 shieldModify=true;
2607 1781224 }
2608
2609
2/2
✓ Branch 0 taken 1159048 times.
✓ Branch 1 taken 1258580 times.
2417628 if(lstep>=6)
2610 {
2611
2/2
✓ Branch 0 taken 324252 times.
✓ Branch 1 taken 934328 times.
1258580 if(dir==up)
2612 {
2613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324252 times.
324252 if ( script_hero_sprite <= 0 ) ++flip;
2614 324252 }
2615 else
2616 {
2617
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 934328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 934328 times.
934328 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2618 }
2619 1258580 }
2620 }
2621
2622 2430717 break;
2623
2624 case las_bszelda: //BS
2625
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 10525 times.
10717 if(action==drowning)
2626 {
2627
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(inwater)
2628 {
2629 192 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2631 192 }
2632 else
2633 {
2634 xofs=oxofs;
2635 yofs=oyofs;
2636 return;
2637 }
2638 192 }
2639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10525 times.
10525 else if (action == sidedrowning)
2640 {
2641 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2642 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2643 }
2644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10525 times.
10525 else if(action==lavadrowning)
2645 {
2646 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2647 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2648 }
2649
2/4
✓ Branch 0 taken 10525 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10525 times.
10525 else if (action == sideswimming || action == sideswimhit)
2650 {
2651 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2652
2653 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2654 }
2655
3/6
✓ Branch 0 taken 10525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10525 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10525 times.
10525 else if(action==swimming || action==swimhit || hopclk==0xFF)
2656 {
2657 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2658 {
2659 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2660 }
2661 else
2662 {
2663 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2664 }
2665 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2666
2667 if(isDiving())
2668 {
2669 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2670 {
2671 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2672 }
2673 else
2674 {
2675 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2676 }
2677 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2678 }
2679 }
2680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10525 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10525 else if(charging > 0 && attack != wHammer)
2681 {
2682 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2683 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2684 }
2685
8/10
✓ Branch 0 taken 10405 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 10405 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1566 times.
✓ Branch 5 taken 8959 times.
✓ Branch 6 taken 1193 times.
✓ Branch 7 taken 373 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1193 times.
10525 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2686 {
2687 1193 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1193 times.
1193 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2689 1193 }
2690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 else if(fallclk>0)
2691 {
2692 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2693 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2694 }
2695
2/6
✓ Branch 0 taken 9332 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9332 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9332 else if(!noliftspr&&action==lifting&&isLifting())
2696 {
2697 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2698 if(script_hero_sprite <= 0)
2699 {
2700 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2701 auto speed = tliftclk/frames;
2702 if (speed < 1) speed = 1;
2703 auto curframe = (tliftclk - liftclk) / speed;
2704 if (!tliftclk) curframe = frames - 1;
2705 if(unsigned(curframe) < frames)
2706 tile += curframe * (extend == 2 ? 2 : 1);
2707 }
2708 }
2709 else
2710 {
2711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 if(IsSideSwim())
2712 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2713
2/4
✓ Branch 0 taken 9332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9332 times.
✗ Branch 3 not taken.
9332 else if(!noliftspr&&isLifting())
2714 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2715 9332 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2716
2717
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7720 times.
9332 if(dir>up)
2718 {
2719 7720 useltm=true;
2720 7720 shieldModify=true;
2721 7720 }
2722
2723 /*
2724 else if (dir==up)
2725 {
2726 useltm=true;
2727 }
2728 */
2729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9332 times.
9332 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2730 }
2731
2732 10717 break;
2733
2734 case las_zelda3slow: //8-frame Zelda 3 (slow)
2735 case las_zelda3: //8-frame Zelda 3
2736 if(action == drowning)
2737 {
2738 if(inwater)
2739 {
2740 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2741 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2742 }
2743 else
2744 {
2745 xofs=oxofs;
2746 yofs=oyofs;
2747 return;
2748 }
2749 }
2750 else if(action == lavadrowning)
2751 {
2752 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2753 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2754
2755 }
2756 else if(action == sidedrowning)
2757 {
2758 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2759 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2760 }
2761 else if (action == sideswimming || action == sideswimhit)
2762 {
2763 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2764
2765 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2766 }
2767 else if(action == swimming || action==swimhit || hopclk==0xFF)
2768 {
2769 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2770 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2771
2772 if(isDiving())
2773 {
2774 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2775 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2776 }
2777 }
2778 else if(charging > 0 && attack != wHammer)
2779 {
2780 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2781 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2782 //int32_t l=hero_count/hero_animation_speed;
2783 int32_t l=(hero_count/hero_animation_speed)&15;
2784 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2785 l-=((l>3)?1:0)+((l>12)?1:0);
2786 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2787 }
2788 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2789 {
2790 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2791 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2792 }
2793 else if(fallclk>0)
2794 {
2795 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2796 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2797 }
2798 else if(!noliftspr&&action==lifting&&isLifting())
2799 {
2800 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2801 if(script_hero_sprite <= 0)
2802 {
2803 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2804 auto speed = tliftclk/frames;
2805 if (speed < 1) speed = 1;
2806 auto curframe = (tliftclk-liftclk)/speed;
2807 if (!tliftclk) curframe = frames - 1;
2808 if(unsigned(curframe) < frames)
2809 tile += curframe * (extend == 2 ? 2 : 1);
2810 }
2811 }
2812 else
2813 {
2814 if(IsSideSwim())
2815 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2816 else if(!noliftspr&&isLifting())
2817 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2818 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2819
2820 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2821 {
2822 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2823 }
2824
2825 if(dir>up)
2826 {
2827 useltm=true;
2828 shieldModify=true;
2829 }
2830
2831 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2832 {
2833 //tile+=(extend==2?2:1);
2834 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2835 int32_t l = hero_count / hero_animation_speed;
2836 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2837 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2838 }
2839 }
2840
2841 break;
2842
2843 default:
2844 break;
2845 }
2846 2441434 }
2847
2848
6/6
✓ Branch 0 taken 2430717 times.
✓ Branch 1 taken 10717 times.
✓ Branch 2 taken 1735482 times.
✓ Branch 3 taken 695235 times.
✓ Branch 4 taken 97966 times.
✓ Branch 5 taken 1637516 times.
2441434 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2849
2850
2/2
✓ Branch 0 taken 2440700 times.
✓ Branch 1 taken 734 times.
2441434 if(action==won)
2851 {
2852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 734 times.
734 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2853 734 }
2854
2855
4/4
✓ Branch 0 taken 2422519 times.
✓ Branch 1 taken 18915 times.
✓ Branch 2 taken 24148 times.
✓ Branch 3 taken 2398371 times.
2441434 if(action==landhold1 || action==landhold2)
2856 {
2857 43063 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2858
5/6
✓ Branch 0 taken 43063 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33008 times.
✓ Branch 3 taken 10055 times.
✓ Branch 4 taken 10837 times.
✓ Branch 5 taken 22171 times.
43063 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2859 43063 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2860 43063 }
2861
3/4
✓ Branch 0 taken 2398111 times.
✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2398111 times.
2398371 else if(action==waterhold1 || action==waterhold2)
2862 {
2863 260 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2864 260 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2865 260 }
2866
2/4
✓ Branch 0 taken 2398111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2398111 times.
2398111 else if(action==sidewaterhold1 || action==sidewaterhold2)
2867 {
2868 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2869 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2870 }
2871
2872
2/4
✓ Branch 0 taken 2441434 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2441434 times.
2441434 if(action!=casting && action!=sideswimcasting)
2873 {
2874
2/2
✓ Branch 0 taken 671846 times.
✓ Branch 1 taken 1769588 times.
2441434 if(useltm)
2875 {
2876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1769588 times.
1769588 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2877 1769588 }
2878 2441434 }
2879
2880 // Stone of Agony
2881
1/2
✓ Branch 0 taken 2441434 times.
✗ Branch 1 not taken.
2441434 if(agony)
2882 {
2883 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2884 }
2885
2886
6/6
✓ Branch 0 taken 615222 times.
✓ Branch 1 taken 1826212 times.
✓ Branch 2 taken 604220 times.
✓ Branch 3 taken 11002 times.
✓ Branch 4 taken 26375 times.
✓ Branch 5 taken 588847 times.
2441434 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2887 {
2888 2415059 masked_draw(dest);
2889 2415059 }
2890
2891 //draw held items after Hero so they don't go behind his head
2892
4/4
✓ Branch 0 taken 2422519 times.
✓ Branch 1 taken 18915 times.
✓ Branch 2 taken 24148 times.
✓ Branch 3 taken 2398371 times.
2441434 if(action==landhold1 || action==landhold2)
2893 {
2894
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 43059 times.
43063 if(holditem > -1)
2895 {
2896
2/2
✓ Branch 0 taken 10760 times.
✓ Branch 1 taken 32299 times.
43059 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2897 {
2898 10760 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2899 10760 }
2900 else
2901 {
2902 32299 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2903 }
2904 43059 }
2905 43063 }
2906
3/4
✓ Branch 0 taken 2398111 times.
✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2398111 times.
2398371 else if(action==waterhold1 || action==waterhold2)
2907 {
2908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(holditem > -1)
2909 {
2910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
260 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2911 {
2912 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2913 }
2914 else
2915 {
2916 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2917 }
2918 260 }
2919 260 }
2920
2/4
✓ Branch 0 taken 2398111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2398111 times.
2398111 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2921 {
2922 if(holditem > -1)
2923 {
2924 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2925 {
2926 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2927 }
2928 else
2929 {
2930 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2931 }
2932 }
2933 }
2934
3/4
✓ Branch 0 taken 9703 times.
✓ Branch 1 taken 2431731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9703 times.
2441434 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2935 {
2936 2431731 xofs=oxofs;
2937 2431731 yofs=oyofs;
2938 2431731 return;
2939 }
2940
2941 9703 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2942 9703 int32_t hearts=0;
2943 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2944 9703 int32_t htile = 2;
2945
2946 9703 do
2947 {
2948 62784 int32_t nx=125;
2949
2950
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 11616 times.
62784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2951 {
2952 11616 nx=x;
2953 11616 }
2954
2955 62784 int32_t ny=88;
2956
2957
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 11616 times.
62784 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2958 {
2959 11616 ny=y;
2960 11616 }
2961
2962 62784 double tx = zc::math::Cos(a2)*53 +nx;
2963 62784 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2964 62784 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2965 62784 a2-=PI/4;
2966 62784 ++hearts;
2967
2/2
✓ Branch 0 taken 53081 times.
✓ Branch 1 taken 9703 times.
125568 }
2968
2/2
✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 58544 times.
62784 while(a2>PI/2 && hearts<8);
2969
2970 9703 xofs=oxofs;
2971 9703 yofs=oyofs;
2972 2774152 }
2973
2974 2731443 void HeroClass::masked_draw(BITMAP* dest)
2975 {
2976
12/12
✓ Branch 0 taken 1967619 times.
✓ Branch 1 taken 763824 times.
✓ Branch 2 taken 1861422 times.
✓ Branch 3 taken 106197 times.
✓ Branch 4 taken 1836176 times.
✓ Branch 5 taken 25246 times.
✓ Branch 6 taken 1808842 times.
✓ Branch 7 taken 27334 times.
✓ Branch 8 taken 1772572 times.
✓ Branch 9 taken 36270 times.
✓ Branch 10 taken 1799305 times.
✓ Branch 11 taken 62117 times.
2731443 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
2977 {
2978 // clip under doorways
2979 62117 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
2980
2981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62117 times.
62117 if(sub!=NULL)
2982 {
2983 62117 yofs -= (playing_field_offset+16);
2984 62117 xofs -= 16;
2985 62117 sprite::draw(sub);
2986
1/2
✓ Branch 0 taken 62117 times.
✗ Branch 1 not taken.
62117 if(lift_wpn)
2987 {
2988 handle_lift(false);
2989 bool shad = lift_wpn->has_shadow;
2990 lift_wpn->has_shadow = false;
2991 lift_wpn->draw(sub);
2992 lift_wpn->has_shadow = shad;
2993 }
2994 62117 prompt_draw(sub);
2995 62117 xofs+=16;
2996 62117 yofs += (playing_field_offset+16);
2997 62117 destroy_bitmap(sub);
2998 62117 }
2999 62117 }
3000 else
3001 {
3002 2669326 sprite::draw(dest);
3003
1/2
✓ Branch 0 taken 2669326 times.
✗ Branch 1 not taken.
2669326 if(lift_wpn)
3004 {
3005 handle_lift(false);
3006 bool shad = lift_wpn->has_shadow;
3007 lift_wpn->has_shadow = false;
3008 lift_wpn->draw(dest);
3009 lift_wpn->has_shadow = shad;
3010 }
3011 2669326 prompt_draw(dest);
3012 }
3013
3014 2731443 return;
3015 }
3016 2731443 void HeroClass::prompt_draw(BITMAP* dest)
3017 {
3018
1/2
✓ Branch 0 taken 2731443 times.
✗ Branch 1 not taken.
2731443 if(!prompt_combo) return;
3019 int32_t sx = real_x(x+xofs+prompt_x);
3020 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3021 sy -= fake_z(fakez);
3022 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3023 return;
3024 2731443 }
3025
3026 4272 void collectitem_script(int32_t id)
3027 {
3028
1/2
✓ Branch 0 taken 4272 times.
✗ Branch 1 not taken.
4272 if(itemsbuf[id].collect_script)
3029 {
3030 //clear item script stack.
3031 //ri = &(itemScriptData[id]);
3032 //ri->Clear();
3033 //itemCollectScriptData[id].Clear();
3034 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3035 ri = &(itemCollectScriptData[id]);
3036 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3037 ri->Clear();
3038 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3039
3040 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3041 {
3042 item_collect_doscript[id] = 1;
3043 itemscriptInitialised[id] = 0;
3044 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3045 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3046 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3047 }
3048 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3049 {
3050 item_collect_doscript[id] = 1;
3051 itemscriptInitialised[id] = 0;
3052 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3053 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3054 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3055 }
3056 //runningItemScripts[id] = 0;
3057 }
3058 4272 }
3059 277 void passiveitem_script(int32_t id, bool doRun = false)
3060 {
3061 //Passive item scripts on colelction
3062
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
277 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3063 {
3064 ri = &(itemScriptData[id]);
3065 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3066 ri->Clear();
3067 item_doscript[id] = 1;
3068 itemscriptInitialised[id] = 0;
3069
3070
3071 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3072 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3073 {
3074 item_doscript[id] = 0;
3075 return;
3076 }
3077 if(doRun)
3078 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3079 }
3080 277 }
3081
3082 // separate case for sword/wand/hammer/slashed weapons only
3083 // the main weapon checking is in the global function check_collisions()
3084 2441644 bool HeroClass::checkstab()
3085 {
3086
12/14
✓ Branch 0 taken 2048651 times.
✓ Branch 1 taken 392993 times.
✓ Branch 2 taken 86276 times.
✓ Branch 3 taken 306717 times.
✓ Branch 4 taken 77772 times.
✓ Branch 5 taken 8504 times.
✓ Branch 6 taken 77772 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 77772 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 71324 times.
✓ Branch 11 taken 6448 times.
✓ Branch 12 taken 93990 times.
✓ Branch 13 taken 227679 times.
2441644 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3087 392993 || (attackclk<=4))
3088 2213965 return false;
3089
3090 227679 weapon *w=NULL;
3091
3092 227679 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3093 227679 bool found = false;
3094 227679 int32_t melee_weapon_index = 0;
3095 227679 int32_t parentitem=-1;
3096 227679 weapon* meleeweap = nullptr;
3097
2/2
✓ Branch 0 taken 25876 times.
✓ Branch 1 taken 257326 times.
283202 for(int32_t i=0; i<Lwpns.Count(); i++)
3098 {
3099 257326 w = (weapon*)Lwpns.spr(i);
3100
3101
5/6
✓ Branch 0 taken 257326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5843 times.
✓ Branch 3 taken 251483 times.
✓ Branch 4 taken 55523 times.
✓ Branch 5 taken 201803 times.
257326 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3102 {
3103 201803 found = true;
3104 201803 melee_weapon_index = i+1;
3105 201803 meleeweap = w;
3106 // Position the sword as Hero slashes with it.
3107
2/4
✓ Branch 0 taken 201803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 201803 times.
201803 if(w->id!=wHammer&&w->id!=wBugNet)
3108 201803 positionSword(w,w->parentitem);
3109
3110 201803 wx=w->x;
3111 201803 wy=w->y;
3112 201803 wz=w->z;
3113 201803 wxsz = w->hxsz;
3114 201803 wysz = w->hysz;
3115 201803 parentitem = w->parentitem;
3116 201803 break;
3117 }
3118 55523 }
3119
3120
5/6
✓ Branch 0 taken 217214 times.
✓ Branch 1 taken 10465 times.
✓ Branch 2 taken 21412 times.
✓ Branch 3 taken 195802 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21412 times.
227679 if(attack==wSword && attackclk>=14 && charging==0)
3121 21412 return false;
3122
3123
2/2
✓ Branch 0 taken 180391 times.
✓ Branch 1 taken 25876 times.
206267 if(!found)
3124 25876 return false;
3125
3126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180391 times.
180391 if(attack == wFire)
3127 return false;
3128
3129
1/2
✓ Branch 0 taken 180391 times.
✗ Branch 1 not taken.
180391 if(attack==wHammer)
3130 {
3131 if(attackclk<15)
3132 {
3133 switch(w->dir)
3134 {
3135 case up:
3136 wx=x-1;
3137 wy=y-4;
3138 break;
3139
3140 case down:
3141 wx=x+8;
3142 wy=y+28;
3143 break; // This is consistent with 2.10
3144
3145 case left:
3146 wx=x-13;
3147 wy=y+14;
3148 break;
3149
3150 case right:
3151 wx=x+21;
3152 wy=y+14;
3153 break;
3154 }
3155
3156 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3157 {
3158 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3159 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3160 switch(dir)
3161 {
3162 case up:
3163 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3164 break;
3165
3166 case down:
3167 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3168 break;
3169
3170 case left:
3171 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3172 break;
3173
3174 case right:
3175 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3176 break;
3177 }
3178 */
3179 }
3180
3181 return false;
3182 }
3183 else if(attackclk==15)
3184 {
3185 // Hammer's reach needs adjusted slightly for backward compatibility
3186 if(w->dir==up)
3187 w->hyofs-=1;
3188 else if(w->dir==left)
3189 w->hxofs-=2;
3190 }
3191 }
3192
3193 // The return of Spaghetti Code Constants!
3194
3/6
✓ Branch 0 taken 5451 times.
✓ Branch 1 taken 174940 times.
✓ Branch 2 taken 174940 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
180391 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180391 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3196 180391 itemid = vbound(itemid, 0, MAXITEMS-1);
3197
3198 // The sword offsets aren't based on anything other than what felt about right
3199 // compared to the NES game and what mostly kept it from hitting things that
3200 // should clearly be out of range. They could probably still use more tweaking.
3201 // Don't use 2.10 for reference; it's pretty far off.
3202 // - Saf
3203
3204
6/6
✓ Branch 0 taken 11606 times.
✓ Branch 1 taken 168785 times.
✓ Branch 2 taken 1008 times.
✓ Branch 3 taken 10598 times.
✓ Branch 4 taken 1008 times.
✓ Branch 5 taken 10598 times.
180391 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3205 {
3206
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2227 times.
✓ Branch 2 taken 2882 times.
✓ Branch 3 taken 3169 times.
✓ Branch 4 taken 2320 times.
10598 switch(w->dir)
3207 {
3208 case up:
3209
2/2
✓ Branch 0 taken 1451 times.
✓ Branch 1 taken 776 times.
2227 if(attackclk<8)
3210 {
3211 776 wy-=4;
3212 776 }
3213
3214 2227 break;
3215
3216 case down:
3217 //if(attackclk<8)
3218 {
3219 2882 wy-=2;
3220 }
3221 2882 break;
3222
3223 case left:
3224
3225 //if(attackclk<8)
3226 {
3227 3169 wx+=2;
3228 }
3229
3230 3169 break;
3231
3232 case right:
3233
3234 //if(attackclk<8)
3235 {
3236 2320 wx-=3;
3237 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3238 }
3239
3240 2320 break;
3241 }
3242 10598 }
3243
3244
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38870 times.
✓ Branch 2 taken 40081 times.
✓ Branch 3 taken 51335 times.
✓ Branch 4 taken 50105 times.
180391 switch(w->dir)
3245 {
3246 case up:
3247 38870 wx+=2;
3248 38870 break;
3249
3250 case down:
3251 40081 break;
3252
3253 case left:
3254 51335 wy-=3;
3255 51335 break;
3256
3257 case right:
3258 50105 wy-=3;
3259 50105 break;
3260 }
3261
3262 180391 wx+=w->hxofs;
3263 180391 wy+=w->hyofs;
3264 180391 wy-=(w->fakez).getInt();
3265
3266
2/2
✓ Branch 0 taken 178491 times.
✓ Branch 1 taken 1007338 times.
1185829 for(int32_t i=0; i<guys.Count(); i++)
3267 {
3268
1/2
✓ Branch 0 taken 1007338 times.
✗ Branch 1 not taken.
1007338 if(attack==wBugNet) break;
3269 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3270
5/6
✓ Branch 0 taken 19256 times.
✓ Branch 1 taken 988082 times.
✓ Branch 2 taken 19185 times.
✓ Branch 3 taken 71 times.
✓ Branch 4 taken 19185 times.
✗ Branch 5 not taken.
1007338 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3271
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 920723 times.
✓ Branch 3 taken 67359 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 988082 times.
988153 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 988082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
988082 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3273 {
3274 // Checking the whimsical ring for every collision check causes
3275 // an odd bug. It's much more likely to activate on a 0-damage
3276 // weapon, since a 0-damage hit won't make the enemy invulnerable
3277 // to damaging hits in the following frames.
3278
3279 19256 int32_t whimsyid = current_item_id(itype_whimsicalring);
3280
3281 19256 int32_t dmg = weaponattackpower(itemid);
3282
1/2
✓ Branch 0 taken 19256 times.
✗ Branch 1 not taken.
19256 if(whimsyid>-1)
3283 {
3284 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3285 dmg += current_item_power(itype_whimsicalring);
3286 else whimsyid = -1;
3287 }
3288 19256 int32_t atkringid = current_item_id(itype_atkring);
3289
1/2
✓ Branch 0 taken 19256 times.
✗ Branch 1 not taken.
19256 if(atkringid>-1)
3290 {
3291 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3292 dmg += itemsbuf[atkringid].misc1; //Additive
3293 }
3294
3295 19256 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn);
3296 19256 enemy *e = (enemy*)guys.spr(i);
3297
2/2
✓ Branch 0 taken 6751 times.
✓ Branch 1 taken 12505 times.
19256 if (h == -1) { e->hitby[HIT_BY_LWEAPON] = melee_weapon_index; } //temp_hit = true; }
3298 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3299
3300
3/4
✓ Branch 0 taken 12505 times.
✓ Branch 1 taken 6751 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12505 times.
19256 if(h<0 && whimsyid>-1)
3301 {
3302 sfx(itemsbuf[whimsyid].usesound);
3303 }
3304
3305
3/4
✓ Branch 0 taken 16684 times.
✓ Branch 1 taken 2572 times.
✓ Branch 2 taken 16684 times.
✗ Branch 3 not taken.
19256 if(h && charging>0)
3306 {
3307 attackclk = SWORDTAPFRAME;
3308 spins=0;
3309 }
3310
3311
6/8
✓ Branch 0 taken 16684 times.
✓ Branch 1 taken 2572 times.
✓ Branch 2 taken 14465 times.
✓ Branch 3 taken 2219 times.
✓ Branch 4 taken 14465 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 14465 times.
19256 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3312 {
3313
2/2
✓ Branch 0 taken 14426 times.
✓ Branch 1 taken 39 times.
14465 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3314 {
3315 39 hithero(i);
3316 39 }
3317 14465 }
3318
3319
2/2
✓ Branch 0 taken 17356 times.
✓ Branch 1 taken 1900 times.
19256 if(h==2)
3320 1900 break;
3321 17356 }
3322 1005438 }
3323
3324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180391 times.
360782 if(attack == wBugNet
3325
2/4
✓ Branch 0 taken 180391 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 180391 times.
180391 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3326
1/2
✓ Branch 0 taken 180391 times.
✗ Branch 1 not taken.
180391 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3327 {
3328
1/4
✓ Branch 0 taken 180391 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180391 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3329
2/2
✓ Branch 0 taken 180391 times.
✓ Branch 1 taken 40981 times.
221372 for(int32_t j=0; j<items.Count(); j++)
3330 {
3331 40981 item* ptr = (item*)items.spr(j);
3332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40981 times.
40981 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3333 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3334
3335
2/4
✓ Branch 0 taken 40981 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40981 times.
✗ Branch 3 not taken.
40981 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3336 continue; //No picking these up unless you have a bottle to fill!
3337
4/6
✓ Branch 0 taken 40981 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5680 times.
✓ Branch 3 taken 35301 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5680 times.
40981 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3338 {
3339
6/8
✓ Branch 0 taken 35301 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12960 times.
✓ Branch 3 taken 22341 times.
✓ Branch 4 taken 22341 times.
✓ Branch 5 taken 12960 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 22341 times.
35301 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3340 {
3341
6/6
✓ Branch 0 taken 21221 times.
✓ Branch 1 taken 1120 times.
✓ Branch 2 taken 309 times.
✓ Branch 3 taken 20912 times.
✓ Branch 4 taken 21221 times.
✓ Branch 5 taken 1120 times.
43562 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3342
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
✓ Branch 2 taken 21221 times.
✗ Branch 3 not taken.
21221 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3343 {
3344 1120 int32_t pickup = ptr->pickup;
3345 1120 int32_t id2 = ptr->id;
3346 1120 int32_t pstr = ptr->pstring;
3347 1120 int32_t pstr_flags = ptr->pickup_string_flags;
3348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
1120 if(!dofairy)
3349 {
3350 1120 std::vector<int32_t> &ev = FFCore.eventData;
3351 1120 ev.clear();
3352 1120 ev.push_back(id2*10000);
3353 1120 ev.push_back(pickup*10000);
3354 1120 ev.push_back(pstr*10000);
3355 1120 ev.push_back(pstr_flags*10000);
3356 1120 ev.push_back(0);
3357 1120 ev.push_back(ptr->getUID());
3358 1120 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3359 1120 ev.push_back(w->getUID());
3360
3361 1120 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3362 1120 bool nullify = ev[4] != 0;
3363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
1120 if(nullify) continue;
3364 1120 id2 = ev[0]/10000;
3365 1120 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3366 1120 pstr = ev[2] / 10000;
3367 1120 pstr_flags = ev[3] / 10000;
3368 1120 }
3369
3370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
1120 if(pickup&ipONETIME) // set mITEM for one-time-only items
3371 setmapflag(mITEM);
3372
1/2
✓ Branch 0 taken 1120 times.
✗ Branch 1 not taken.
1120 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3373 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3374
3375
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1120 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3376 setxmapflag(1<<ptr->pickupexstate);
3377
1/2
✓ Branch 0 taken 1120 times.
✗ Branch 1 not taken.
1120 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3378 {
3379 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3380 hidden_entrance(0, true, false, -5);
3381 }
3382 //!DIMI
3383
3384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
1120 if(dofairy)
3385 {
3386 game->fillBottle(itemsbuf[ptr->id].misc4);
3387 }
3388 else
3389 {
3390 1120 collectitem_script(id2);
3391
3392 1120 getitem(id2, false, true);
3393 }
3394 1120 items.del(j);
3395
3396
2/2
✓ Branch 0 taken 1353 times.
✓ Branch 1 taken 1120 times.
2473 for(int32_t i=0; i<Lwpns.Count(); i++)
3397 {
3398 1353 weapon *w2 = (weapon*)Lwpns.spr(i);
3399
3400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1353 times.
1353 if(w2->dragging==j)
3401 {
3402 w2->dragging=-1;
3403 }
3404
1/2
✓ Branch 0 taken 1353 times.
✗ Branch 1 not taken.
1353 else if(w2->dragging>j)
3405 {
3406 w2->dragging-=1;
3407 }
3408 1353 }
3409
3410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1120 if ( (pstr > 0 && pstr < msg_count) )
3411 {
3412 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3413 {
3414 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3415 FFCore.SetItemMessagePlayed(id2);
3416 donewmsg(pstr);
3417 break;
3418 }
3419 }
3420
3421 1120 --j;
3422 1120 }
3423 22341 }
3424 35301 }
3425 40981 }
3426 180391 }
3427
3428
2/4
✓ Branch 0 taken 180391 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 180391 times.
180391 if(attack==wCByrna || attack==wBugNet)
3429 return false;
3430
3431
2/2
✓ Branch 0 taken 174940 times.
✓ Branch 1 taken 5451 times.
180391 if(attack==wSword)
3432 {
3433
2/2
✓ Branch 0 taken 152955 times.
✓ Branch 1 taken 21985 times.
174940 if(attackclk == 6)
3434 {
3435
2/2
✓ Branch 0 taken 3869360 times.
✓ Branch 1 taken 21985 times.
3891345 for(int32_t q=0; q<176; q++)
3436 {
3437 3869360 set_bit(screengrid,q,0);
3438 3869360 set_bit(screengrid_layer[0],q,0);
3439 3869360 set_bit(screengrid_layer[1],q,0);
3440
3441 3869360 }
3442
3443
2/2
✓ Branch 0 taken 351760 times.
✓ Branch 1 taken 21985 times.
373745 for(dword q = MAXFFCS/8; q > 0; --q)
3444 351760 ffcgrid[q-1] = 0;
3445 21985 }
3446
3447
4/4
✓ Branch 0 taken 38300 times.
✓ Branch 1 taken 136640 times.
✓ Branch 2 taken 19015 times.
✓ Branch 3 taken 19285 times.
174940 if(dir==up && ((x.getInt()&15)==0))
3448 {
3449 19285 check_slash_block(wx,wy);
3450 19285 check_slash_block(wx,wy+8);
3451
3452 //layers
3453 19285 check_slash_block_layer(wx,wy,1);
3454 19285 check_slash_block_layer(wx,wy+8,1);
3455 19285 check_slash_block_layer(wx,wy,1);
3456 19285 check_slash_block_layer(wx,wy+8,1);
3457 //2
3458 19285 check_slash_block_layer(wx,wy,2);
3459 19285 check_slash_block_layer(wx,wy+8,2);
3460 19285 check_slash_block_layer(wx,wy,2);
3461 19285 check_slash_block_layer(wx,wy+8,2);
3462
3463
3464
3465 19285 }
3466
3/8
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 136640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19015 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
155655 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3467 {
3468 19015 check_slash_block(wx,wy);
3469 19015 check_slash_block(wx,wy+8);
3470 19015 check_slash_block(wx+8,wy);
3471 19015 check_slash_block(wx+8,wy+8);
3472 ///layer 1
3473 19015 check_slash_block_layer(wx,wy,1);
3474 19015 check_slash_block_layer(wx,wy+8,1);
3475 19015 check_slash_block_layer(wx+8,wy,1);
3476 19015 check_slash_block_layer(wx+8,wy+8,1);
3477 ///layer 2
3478 19015 check_slash_block_layer(wx,wy,2);
3479 19015 check_slash_block_layer(wx,wy+8,2);
3480 19015 check_slash_block_layer(wx+8,wy,2);
3481 19015 check_slash_block_layer(wx+8,wy+8,2);
3482 19015 }
3483
3484
4/4
✓ Branch 0 taken 39168 times.
✓ Branch 1 taken 135772 times.
✓ Branch 2 taken 20882 times.
✓ Branch 3 taken 18286 times.
174940 if(dir==down && ((x.getInt()&15)==0))
3485 {
3486 20882 check_slash_block(wx,wy+wysz-8);
3487 20882 check_slash_block(wx,wy+wysz);
3488
3489 //layer 1
3490 20882 check_slash_block_layer(wx,wy+wysz-8,1);
3491 20882 check_slash_block_layer(wx,wy+wysz,1);
3492 //layer 2
3493 20882 check_slash_block_layer(wx,wy+wysz-8,2);
3494 20882 check_slash_block_layer(wx,wy+wysz,2);
3495 20882 }
3496
3/8
✓ Branch 0 taken 18286 times.
✓ Branch 1 taken 135772 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18286 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
154058 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3497 {
3498 18286 check_slash_block(wx,wy+wysz-8);
3499 18286 check_slash_block(wx,wy+wysz);
3500 18286 check_slash_block(wx+8,wy+wysz-8);
3501 18286 check_slash_block(wx+8,wy+wysz);
3502 //layer 1
3503 18286 check_slash_block_layer(wx,wy+wysz-8,1);
3504 18286 check_slash_block_layer(wx,wy+wysz,1);
3505 18286 check_slash_block_layer(wx+8,wy+wysz-8,1);
3506 18286 check_slash_block_layer(wx+8,wy+wysz,1);
3507 //layer 2
3508 18286 check_slash_block_layer(wx,wy+wysz-8,2);
3509 18286 check_slash_block_layer(wx,wy+wysz,2);
3510 18286 check_slash_block_layer(wx+8,wy+wysz-8,2);
3511 18286 check_slash_block_layer(wx+8,wy+wysz,2);
3512 18286 }
3513
3514
2/2
✓ Branch 0 taken 126094 times.
✓ Branch 1 taken 48846 times.
174940 if(dir==left)
3515 {
3516 48846 check_slash_block(wx,wy+8);
3517 48846 check_slash_block(wx+8,wy+8);
3518 //layer 1
3519 48846 check_slash_block_layer(wx,wy+8,1);
3520 48846 check_slash_block_layer(wx+8,wy+8,1);
3521 //layer 2
3522 48846 check_slash_block_layer(wx,wy+8,2);
3523 48846 check_slash_block_layer(wx+8,wy+8,2);
3524 48846 }
3525
3526
2/2
✓ Branch 0 taken 126314 times.
✓ Branch 1 taken 48626 times.
174940 if(dir==right)
3527 {
3528 48626 check_slash_block(wx+wxsz,wy+8);
3529 48626 check_slash_block(wx+wxsz-8,wy+8);
3530 //layer 1
3531 48626 check_slash_block_layer(wx+wxsz,wy+8,1);
3532 48626 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3533 //layer 2
3534 48626 check_slash_block_layer(wx+wxsz,wy+8,2);
3535 48626 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3536 48626 }
3537 174940 }
3538
1/2
✓ Branch 0 taken 5451 times.
✗ Branch 1 not taken.
5451 else if(attack==wWand)
3539 {
3540
1/2
✓ Branch 0 taken 5451 times.
✗ Branch 1 not taken.
5451 if(attackclk == 5)
3541 {
3542 for(int32_t q=0; q<176; q++)
3543 {
3544 set_bit(screengrid,q,0);
3545 set_bit(screengrid_layer[0],q,0);
3546 set_bit(screengrid_layer[1],q,0);
3547 }
3548
3549 for(dword q = MAXFFCS/8; q > 0; --q)
3550 ffcgrid[q-1] = 0;
3551 }
3552
3553 // cutable blocks
3554
4/4
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 4881 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 372 times.
5451 if(dir==up && (x.getInt()&15)==0)
3555 {
3556 372 check_wand_block(wx,wy);
3557 372 check_wand_block(wx,wy+8);
3558 372 }
3559
3/8
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 4881 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5079 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3560 {
3561 198 check_wand_block(wx,wy);
3562 198 check_wand_block(wx,wy+8);
3563 198 check_wand_block(wx+8,wy);
3564 198 check_wand_block(wx+8,wy+8);
3565 198 }
3566
3567
4/4
✓ Branch 0 taken 913 times.
✓ Branch 1 taken 4538 times.
✓ Branch 2 taken 519 times.
✓ Branch 3 taken 394 times.
5451 if(dir==down && (x.getInt()&15)==0)
3568 {
3569 394 check_wand_block(wx,wy+wysz-8);
3570 394 check_wand_block(wx,wy+wysz);
3571 394 }
3572
3/8
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 4538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 519 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5057 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3573 {
3574 519 check_wand_block(wx,wy+wysz-8);
3575 519 check_wand_block(wx,wy+wysz);
3576 519 check_wand_block(wx+8,wy+wysz-8);
3577 519 check_wand_block(wx+8,wy+wysz);
3578 519 }
3579
3580
2/2
✓ Branch 0 taken 2962 times.
✓ Branch 1 taken 2489 times.
5451 if(dir==left)
3581 {
3582 2489 check_wand_block(wx,y+8);
3583 2489 check_wand_block(wx+8,y+8);
3584 2489 }
3585
3586
2/2
✓ Branch 0 taken 3972 times.
✓ Branch 1 taken 1479 times.
5451 if(dir==right)
3587 {
3588 1479 check_wand_block(wx+wxsz,y+8);
3589 1479 check_wand_block(wx+wxsz-8,y+8);
3590 1479 }
3591 5451 }
3592 else if((attack==wHammer) && ((attackclk==15) || ( spins==1 && attackclk >=15 ))) //quake hammer should be spins == 1
3593 //else if((attack==wHammer) && (attackclk==15))
3594 //reverting this, because it breaks multiple-hit pegs
3595 //else if((attack==wHammer) && (attackclk>=15)) //>= instead of == for time it takes to charge up hammer with quake scrolls.
3596 {
3597 // poundable blocks
3598 for(int32_t q=0; q<176; q++)
3599 {
3600 set_bit(screengrid,q,0);
3601 set_bit(screengrid_layer[0],q,0);
3602 set_bit(screengrid_layer[1],q,0);
3603 }
3604
3605 for(dword q = MAXFFCS/8; q > 0; --q)
3606 ffcgrid[q-1] = 0;
3607
3608 if(dir==up && (x.getInt()&15)==0)
3609 {
3610 check_pound_block(wx,wy);
3611 check_pound_block(wx,wy+8);
3612 }
3613 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3614 {
3615 check_pound_block(wx,wy);
3616 check_pound_block(wx,wy+8);
3617 check_pound_block(wx+8,wy);
3618 check_pound_block(wx+8,wy+8);
3619 }
3620
3621 if(dir==down && (x.getInt()&15)==0)
3622 {
3623 check_pound_block(wx,wy+wysz-8);
3624 check_pound_block(wx,wy+wysz);
3625 }
3626 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3627 {
3628 check_pound_block(wx,wy+wysz-8);
3629 check_pound_block(wx,wy+wysz);
3630 check_pound_block(wx+8,wy+wysz-8);
3631 check_pound_block(wx+8,wy+wysz);
3632 }
3633
3634 if(dir==left)
3635 {
3636 check_pound_block(wx,y+8);
3637 check_pound_block(wx+8,y+8);
3638 }
3639
3640 if(dir==right)
3641 {
3642 check_pound_block(wx+wxsz,y+8);
3643 check_pound_block(wx+wxsz-8,y+8);
3644 }
3645 }
3646 else
3647 {
3648 return false;
3649 }
3650
3651 180391 return true;
3652 2441644 }
3653
3654 926104 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3655 {
3656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 926104 times.
926104 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3657 {
3658 //zprint("bit off\n");
3659 926104 return;
3660 }
3661 //keep things inside the screen boundaries
3662 bx=vbound(bx, 0, 255);
3663 by=vbound(by, 0, 176);
3664 int32_t fx=vbound(bx, 0, 255);
3665 int32_t fy=vbound(by, 0, 176);
3666 //first things first
3667 if(attack!=wSword)
3668 return;
3669
3670 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3671 || (attackclk>SWORDTAPFRAME && tapping))
3672 return;
3673
3674 //find out which combo row/column the coordinates are in
3675 bx &= 0xF0;
3676 by &= 0xF0;
3677
3678
3679 int32_t flag = MAPFLAGL(layer,bx,by);
3680 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3681 int32_t cid = MAPCOMBOL(layer,bx,by);
3682 int32_t type = combobuf[cid].type;
3683 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3684 type = cNONE;
3685 //zprint("cid is: %d\n", cid);
3686 //zprint("type is: %d\n", type);
3687 int32_t i = (bx>>4) + by;
3688
3689 if(i > 175)
3690 return;
3691
3692 bool ignorescreen=false;
3693
3694 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3695 return;
3696
3697 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3698
3699 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3700 if(isCuttableNextType(type))
3701 {
3702 FFCore.tempScreens[layer]->data[i]++;
3703 }
3704 else
3705 {
3706 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3707 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3708 FFCore.tempScreens[layer]->sflag[i] = 0;
3709 }
3710 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3711 {
3712 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3713 sfx(tmpscr->secretsfx);
3714 }
3715 else if(isCuttableItemType(type))
3716 {
3717 int32_t it = -1;
3718 int32_t thedropset = -1;
3719
3720 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3721 if ( (combobuf[cid].usrflags&cflag2) )
3722 {
3723 if(combobuf[cid].usrflags&cflag11)
3724 it = combobuf[cid].attribytes[1];
3725 else
3726 {
3727 it = select_dropitem(combobuf[cid].attribytes[1]);
3728 thedropset = combobuf[cid].attribytes[1];
3729 }
3730 }
3731 else
3732 {
3733 it = select_dropitem(12);
3734 thedropset = 12;
3735 }
3736 if(it!=-1)
3737 {
3738 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3739 itm->from_dropset = thedropset;
3740 items.add(itm);
3741 }
3742 }
3743
3744 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3745
3746 if(get_bit(quest_rules,qr_MORESOUNDS))
3747 {
3748 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3749 {
3750 if (combobuf[cid].usrflags&cflag3)
3751 {
3752 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3753 }
3754 }
3755 else
3756 {
3757 if (combobuf[cid].usrflags&cflag3)
3758 {
3759 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3760 }
3761 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3762 }
3763 }
3764
3765 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3766 if(decotype > 3) decotype = 0;
3767 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3768 switch(decotype)
3769 {
3770 case -2: break; //nothing
3771 case -1:
3772 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3773 break;
3774 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3775 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3776 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3777 }
3778 926104 }
3779
3780 424482 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3781 {
3782 //keep things inside the screen boundaries
3783 424482 bx=vbound(bx, 0, 255);
3784 424482 by=vbound(by, 0, 176);
3785 424482 int32_t fx=vbound(bx, 0, 255);
3786 424482 int32_t fy=vbound(by, 0, 176);
3787 //first things first
3788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424482 times.
424482 if(attack!=wSword)
3789 return;
3790
3791
3/6
✓ Branch 0 taken 424482 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424482 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 52060 times.
476542 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3792
3/4
✓ Branch 0 taken 424482 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52060 times.
✓ Branch 3 taken 372422 times.
424482 || (attackclk>SWORDTAPFRAME && tapping))
3793 return;
3794
3795 //find out which combo row/column the coordinates are in
3796 424482 bx &= 0xF0;
3797 424482 by &= 0xF0;
3798
3799 424482 int32_t type = COMBOTYPE(bx,by);
3800 424482 int32_t type2 = FFCOMBOTYPE(fx,fy);
3801 424482 int32_t flag = MAPFLAG(bx,by);
3802 424482 int32_t flag2 = MAPCOMBOFLAG(bx,by);
3803 424482 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
3804 424482 int32_t cid = MAPCOMBO(bx,by);
3805 424482 int32_t i = (bx>>4) + by;
3806
3807
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 424468 times.
424482 if(i > 175)
3808 14 return;
3809
3810 424468 bool ignorescreen=false;
3811 424468 bool ignoreffc=false;
3812
3813
2/2
✓ Branch 0 taken 5435 times.
✓ Branch 1 taken 419033 times.
424468 if(get_bit(screengrid, i) != 0)
3814 {
3815 5435 ignorescreen = true;
3816 5435 }
3817
1/2
✓ Branch 0 taken 419033 times.
✗ Branch 1 not taken.
419033 else if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3818 ignorescreen = true;
3819
3820 424468 int32_t current_ffcombo = getFFCAt(fx,fy);
3821
3822
3823
3/4
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 423583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
424468 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3824 {
3825 423583 ignoreffc = true;
3826 423583 }
3827
1/2
✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
885 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
3828 ignoreffc = true;
3829
3830
3/4
✓ Branch 0 taken 422311 times.
✓ Branch 1 taken 2157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422310 times.
846778 if(!isCuttableType(type) &&
3831
5/6
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 421970 times.
✓ Branch 2 taken 422310 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422310 times.
422311 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3832 {
3833 422310 ignorescreen = true;
3834 422310 }
3835
3836
2/4
✓ Branch 0 taken 424468 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424468 times.
848936 if(!isCuttableType(type2) &&
3837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424468 times.
424468 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3838 {
3839 424468 ignoreffc = true;
3840 424468 }
3841
3842 424468 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3843
3844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 424468 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
424468 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3845 424468 byte skipsecrets = 0;
3846
3847
2/2
✓ Branch 0 taken 422313 times.
✓ Branch 1 taken 2155 times.
424468 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3848 {
3849
1/2
✓ Branch 0 taken 2155 times.
✗ Branch 1 not taken.
2155 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3850 {
3851 2155 skipsecrets = 0;
3852 2155 }
3853 else skipsecrets = 1; ;
3854 2155 }
3855
3856
3/6
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 423853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 615 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
424468 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3857 {
3858
3/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
615 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3859 {
3860 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3861 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3862 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3863 }
3864
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 612 times.
615 else if(flag == mfARMOS_SECRET)
3865 {
3866 3 s->data[i] = s->secretcombo[sSTAIRS];
3867 3 s->cset[i] = s->secretcset[sSTAIRS];
3868 3 s->sflag[i] = s->secretflag[sSTAIRS];
3869 3 sfx(tmpscr->secretsfx);
3870 3 }
3871
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 611 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 611 times.
612 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3872 {
3873
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3874 {
3875 4 findentrance(bx,by,mfSWORD+i2,true);
3876 4 }
3877
3878 1 findentrance(bx,by,mfSTRIKE,true);
3879 1 }
3880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
611 else if(((flag2 >= 16)&&(flag2 <= 31)))
3881 {
3882 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3883 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3884 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3885 }
3886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 else if(flag2 == mfARMOS_SECRET)
3887 {
3888 s->data[i] = s->secretcombo[sSTAIRS];
3889 s->cset[i] = s->secretcset[sSTAIRS];
3890 s->sflag[i] = s->secretflag[sSTAIRS];
3891 sfx(tmpscr->secretsfx);
3892 }
3893
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 611 times.
611 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3894 {
3895 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3896 {
3897 findentrance(bx,by,mfSWORD+i2,true);
3898 }
3899
3900 findentrance(bx,by,mfSTRIKE,true);
3901 }
3902 else
3903 {
3904
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(isCuttableNextType(type))
3905 {
3906 611 s->data[i]++;
3907 611 }
3908 else
3909 {
3910 s->data[i] = s->undercombo;
3911 s->cset[i] = s->undercset;
3912 s->sflag[i] = 0;
3913 }
3914
3915 //pausenow=true;
3916 }
3917 615 }
3918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423853 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423853 else if(!ignorescreen && skipsecrets)
3919 {
3920 if(isCuttableNextType(type))
3921 {
3922 s->data[i]++;
3923 }
3924 else
3925 {
3926 s->data[i] = s->undercombo;
3927 s->cset[i] = s->undercset;
3928 s->sflag[i] = 0;
3929 }
3930 }
3931
3932
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 424468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424468 times.
424468 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3933 {
3934 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3935 {
3936 findentrance(bx,by,mfSWORD+i2,true);
3937 }
3938
3939 findentrance(fx,fy,mfSTRIKE,true);
3940 }
3941
1/2
✓ Branch 0 taken 424468 times.
✗ Branch 1 not taken.
424468 else if(!ignoreffc)
3942 {
3943 if(isCuttableNextType(type2))
3944 {
3945 s->ffcs[current_ffcombo].incData(1);
3946 }
3947 else
3948 {
3949 s->ffcs[current_ffcombo].setData(s->undercombo);
3950 s->ffcs[current_ffcombo].cset = s->undercset;
3951 }
3952 }
3953
3954
2/2
✓ Branch 0 taken 423853 times.
✓ Branch 1 taken 615 times.
424468 if(!ignorescreen)
3955 {
3956
2/4
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 615 times.
615 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
3957
3958
5/8
✓ Branch 0 taken 613 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 613 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
615 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3959 {
3960
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3961 2 sfx(tmpscr->secretsfx);
3962 2 }
3963
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 610 times.
613 else if(isCuttableItemType(type))
3964 {
3965 610 int32_t it = -1;
3966 610 int32_t thedropset = -1;
3967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
3968 {
3969 if ( combobuf[cid].usrflags&cflag11 )
3970 {
3971 it = combobuf[cid].attribytes[1];
3972 }
3973 else
3974 {
3975 it = select_dropitem(combobuf[cid].attribytes[1]);
3976 thedropset = combobuf[cid].attribytes[1];
3977 }
3978 }
3979 else
3980 {
3981 610 it = select_dropitem(12);
3982 610 thedropset = 12;
3983 }
3984
3985
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 149 times.
610 if(it!=-1)
3986 {
3987
4/8
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149 times.
✗ Branch 7 not taken.
149 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3988 149 itm->from_dropset = thedropset;
3989 149 items.add(itm);
3990 149 }
3991 610 }
3992
3993 615 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
3994
3995
1/2
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
615 if(get_bit(quest_rules,qr_MORESOUNDS))
3996 {
3997 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3998 {
3999 if (combobuf[cid].usrflags&cflag3)
4000 {
4001 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4002 }
4003 }
4004 else
4005 {
4006 if (combobuf[cid].usrflags&cflag3)
4007 {
4008 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4009 }
4010 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4011 }
4012 }
4013
4014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
615 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4015
1/2
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
615 if(decotype > 3) decotype = 0;
4016
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 615 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 489 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 489 times.
✓ Branch 6 taken 486 times.
✓ Branch 7 taken 3 times.
615 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4017
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 486 times.
615 switch(decotype)
4018 {
4019 3 case -2: break; //nothing
4020 case -1:
4021 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4022 break;
4023
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4024 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4025
3/6
✓ Branch 0 taken 486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 486 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 486 times.
✗ Branch 5 not taken.
486 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4026 }
4027 615 }
4028
4029
1/2
✓ Branch 0 taken 424468 times.
✗ Branch 1 not taken.
424468 if(!ignoreffc)
4030 {
4031 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4032
4033 if(isCuttableItemType(type2))
4034 {
4035 int32_t it=-1;
4036 int32_t thedropset=-1;
4037 if ( (combobuf[cid].usrflags&cflag2) )
4038 {
4039 if(combobuf[cid].usrflags&cflag11)
4040 it = combobuf[cid].attribytes[1];
4041 else
4042 {
4043 it = select_dropitem(combobuf[cid].attribytes[1]);
4044 thedropset = combobuf[cid].attribytes[1];
4045 }
4046 }
4047 else
4048 {
4049 int32_t r=zc_oldrand()%100;
4050
4051 if(r<15)
4052 {
4053 it=iHeart; // 15%
4054 }
4055 else if(r<35)
4056 {
4057 it=iRupy; // 20%
4058 }
4059 }
4060
4061 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4062 {
4063 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4064 itm->from_dropset = thedropset;
4065 items.add(itm);
4066 }
4067 }
4068
4069 if(get_bit(quest_rules,qr_MORESOUNDS))
4070 {
4071 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4072 {
4073 if (combobuf[cid].usrflags&cflag3)
4074 {
4075 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4076 }
4077 }
4078 else
4079 {
4080 if (combobuf[cid].usrflags&cflag3)
4081 {
4082 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4083 }
4084 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4085 }
4086 }
4087
4088 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4089 if(decotype > 3) decotype = 0;
4090 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4091 switch(decotype)
4092 {
4093 case -2: break; //nothing
4094 case -1:
4095 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4096 break;
4097 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4098 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4099 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4100 }
4101 }
4102 424482 }
4103
4104 4928744 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4105 {
4106 /*
4107 int32_t par_item = w->parentitem;
4108 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4109 int32_t usewpn = -1;
4110 if ( par_item > -1 )
4111 {
4112 usewpn = itemsbuf[par_item].useweapon;
4113 }
4114 else if ( par_item == -1 && w->ScriptGenerated )
4115 {
4116 usewpn = w->useweapon;
4117 }
4118 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4119
4120 */
4121 4928744 bx=vbound(bx, 0, 255);
4122 4928744 by=vbound(by, 0, 176);
4123 4928744 int32_t cid = MAPCOMBO(bx,by);
4124
1/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4928744 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
4928744 switch(w->useweapon)
4125 {
4126 case wArrow:
4127 findentrance(bx,by,mfARROW,true);
4128 findentrance(bx,by,mfSARROW,true);
4129 findentrance(bx,by,mfGARROW,true);
4130 break;
4131 case wBeam:
4132 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4133 break;
4134 case wHookshot:
4135 findentrance(bx,by,mfHOOKSHOT,true);
4136 break;
4137 case wBrang:
4138 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4139 break;
4140 case wMagic:
4141 findentrance(bx,by,mfWANDMAGIC,true);
4142 break;
4143 case wRefMagic:
4144 findentrance(bx,by,mfWANDMAGIC,true);
4145 break;
4146 case wRefBeam:
4147 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4148 break;
4149 //reflected magic needs to happen in mirrors:
4150 //
4151 //findentrance(bx,by,mfREFMAGIC,true)
4152 case wRefFireball:
4153 findentrance(bx,by,mfREFFIREBALL,true);
4154 break;
4155 case wBomb:
4156 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4157 break;
4158
4159 case wSBomb:
4160 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4161 break;
4162
4163 case wFire:
4164 findentrance(bx,by,mfBCANDLE,true);
4165 findentrance(bx,by,mfRCANDLE,true);
4166 findentrance(bx,by,mfWANDFIRE,true);
4167 /* if we want the weapon to die
4168 if (findentrance(bx,by,mfBCANDLE,true) ) dead = 1;
4169 if (findentrance(bx,by,mfRCANDLE,true) ) dead = 1;
4170 if (findentrance(bx,by,mfWANDFIRE,true)) dead = 1;
4171 */
4172 break;
4173
4174 case wScript1:
4175 break;
4176 case wScript2:
4177 break;
4178 case wScript3:
4179 break;
4180 case wScript4:
4181 break;
4182 case wScript5:
4183 break;
4184 case wScript6:
4185 break;
4186 case wScript7:
4187 break;
4188 case wScript8:
4189 break;
4190 case wScript9:
4191 break;
4192 case wScript10:
4193 break;
4194 case wIce:
4195 break;
4196 case wCByrna:
4197 break;
4198 case wWhistle:
4199 break;
4200 case wSSparkle:
4201 case wFSparkle:
4202 break;
4203 case wWind:
4204 break;
4205 case wBait:
4206 break;
4207 case wFlame:
4208 case wThrown:
4209 case wBombos:
4210 case wEther:
4211 case wQuake:
4212 case wSwordLA:
4213 case wSword180:
4214 case wStomp:
4215 break;
4216 case wSword:
4217 case wWand:
4218 //case wCandle:
4219 case wHSHandle:
4220 case wLitBomb:
4221 case wLitSBomb:
4222 break;
4223 4928744 default: break;
4224
4225 }
4226 4928744 }
4227
4228 9857488 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4229 {
4230
4231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9857488 times.
9857488 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4232 {
4233 //zprint("bit off\n");
4234 9857488 return;
4235 }
4236 //keep things inside the screen boundaries
4237 bx=vbound(bx, 0, 255);
4238 by=vbound(by, 0, 176);
4239 int32_t fx=vbound(bx, 0, 255);
4240 int32_t fy=vbound(by, 0, 176);
4241 //first things first
4242 if(w->useweapon != wSword)
4243 return;
4244
4245 //find out which combo row/column the coordinates are in
4246 bx &= 0xF0;
4247 by &= 0xF0;
4248
4249
4250 int32_t flag = MAPFLAGL(layer,bx,by);
4251 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4252 int32_t cid = MAPCOMBOL(layer,bx,by);
4253 int32_t type = combobuf[cid].type;
4254 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4255 type = cNONE;
4256 //zprint("cid is: %d\n", cid);
4257 //zprint("type is: %d\n", type);
4258 int32_t i = (bx>>4) + by;
4259
4260 if(i > 175)
4261 return;
4262
4263 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4264 {
4265 return;
4266 //ignorescreen = true;
4267 //zprint("ignoring\n");
4268 }
4269
4270 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4271
4272 {
4273 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4274 if(isCuttableNextType(type) || isCuttableNextType(type))
4275 {
4276 FFCore.tempScreens[layer]->data[i]++;
4277 }
4278 else
4279 {
4280 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4281 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4282 FFCore.tempScreens[layer]->sflag[i] = 0;
4283 }
4284 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4285 {
4286 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4287 sfx(tmpscr->secretsfx);
4288 }
4289 else if(isCuttableItemType(type))
4290 {
4291 int32_t it = -1;
4292 int32_t thedropset = -1;
4293
4294 if ( (combobuf[cid].usrflags&cflag2) )
4295 {
4296 if(combobuf[cid].usrflags&cflag11)
4297 it = combobuf[cid].attribytes[1];
4298 else
4299 {
4300 it = select_dropitem(combobuf[cid].attribytes[1]);
4301 thedropset = combobuf[cid].attribytes[1];
4302 }
4303 }
4304 else
4305 {
4306 it = select_dropitem(12);
4307 thedropset = 12;
4308 }
4309
4310 if(it!=-1)
4311 {
4312 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4313 itm->from_dropset = thedropset;
4314 items.add(itm);
4315 }
4316 }
4317
4318 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4319
4320 if(get_bit(quest_rules,qr_MORESOUNDS))
4321 {
4322 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4323 {
4324 if (combobuf[cid].usrflags&cflag3)
4325 {
4326 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4327 }
4328 }
4329 else
4330 {
4331 if (combobuf[cid].usrflags&cflag3)
4332 {
4333 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4334 }
4335 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4336 }
4337 }
4338
4339 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4340 if(decotype > 3) decotype = 0;
4341 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4342 switch(decotype)
4343 {
4344 case -2: break; //nothing
4345 case -1:
4346 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4347 break;
4348 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4349 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4350 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4351 }
4352
4353 }
4354
4355 9857488 }
4356
4357 4928744 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4358 {
4359 /*
4360 int32_t par_item = w->parentitem;
4361 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4362 int32_t usewpn = -1;
4363 if ( par_item > -1 )
4364 {
4365 usewpn = itemsbuf[par_item].useweapon;
4366 }
4367 else if ( par_item == -1 && w->ScriptGenerated )
4368 {
4369 usewpn = w->useweapon;
4370 }
4371 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4372 */
4373
4374
4375 //keep things inside the screen boundaries
4376 4928744 bx=vbound(bx, 0, 255);
4377 4928744 by=vbound(by, 0, 176);
4378 4928744 int32_t fx=vbound(bx, 0, 255);
4379 4928744 int32_t fy=vbound(by, 0, 176);
4380 4928744 int32_t cid = MAPCOMBO(bx,by);
4381
4382 //find out which combo row/column the coordinates are in
4383 4928744 bx &= 0xF0;
4384 4928744 by &= 0xF0;
4385
4386 4928744 int32_t type = COMBOTYPE(bx,by);
4387 4928744 int32_t type2 = FFCOMBOTYPE(fx,fy);
4388 4928744 int32_t flag = MAPFLAG(bx,by);
4389 4928744 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4390 4928744 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4391
1/2
✓ Branch 0 taken 4928744 times.
✗ Branch 1 not taken.
4928744 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4392 type = cNONE;
4393 4928744 byte dontignore = 0;
4394 4928744 byte dontignoreffc = 0;
4395
4396
3/4
✓ Branch 0 taken 157345 times.
✓ Branch 1 taken 4771399 times.
✓ Branch 2 taken 157345 times.
✗ Branch 3 not taken.
4928744 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4397 {
4398 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4399 dontignore = 1;
4400 }
4401
4402 /*to-do, ffcs
4403 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4404 {
4405 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4406 dontignoreffc = 1;
4407 }*/
4408
2/4
✓ Branch 0 taken 4928744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4928744 times.
✗ Branch 3 not taken.
4928744 if(w->useweapon != wSword && !dontignore) return;
4409
4410
4411 int32_t i = (bx>>4) + by;
4412 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4413
4414 if(i > 175)
4415 return;
4416
4417 bool ignorescreen=false;
4418 bool ignoreffc=false;
4419
4420 if(get_bit(w->wscreengrid, i) != 0)
4421 {
4422 ignorescreen = true; dontignore = 0;
4423 }
4424
4425 int32_t current_ffcombo = getFFCAt(fx,fy);
4426
4427 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4428 {
4429 ignoreffc = true;
4430 }
4431 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4432 type2 = cNONE;
4433 if(!isCuttableType(type) &&
4434 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4435 {
4436 ignorescreen = true;
4437 }
4438
4439 if(!isCuttableType(type2) &&
4440 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4441 {
4442 ignoreffc = true;
4443 }
4444
4445 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4446
4447 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4448 byte skipsecrets = 0;
4449 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4450 {
4451 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4452 {
4453 skipsecrets = 0;
4454 }
4455 else skipsecrets = 1;
4456 }
4457 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4458 {
4459 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4460 {
4461 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4462 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4463 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4464 }
4465 else if(flag == mfARMOS_SECRET)
4466 {
4467 s->data[i] = s->secretcombo[sSTAIRS];
4468 s->cset[i] = s->secretcset[sSTAIRS];
4469 s->sflag[i] = s->secretflag[sSTAIRS];
4470 sfx(tmpscr->secretsfx);
4471 }
4472 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4473 {
4474 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4475 {
4476 findentrance(bx,by,mfSWORD+i2,true);
4477 }
4478
4479 findentrance(bx,by,mfSTRIKE,true);
4480 }
4481 else if(((flag2 >= 16)&&(flag2 <= 31)))
4482 {
4483 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4484 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4485 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4486 }
4487 else if(flag2 == mfARMOS_SECRET)
4488 {
4489 s->data[i] = s->secretcombo[sSTAIRS];
4490 s->cset[i] = s->secretcset[sSTAIRS];
4491 s->sflag[i] = s->secretflag[sSTAIRS];
4492 sfx(tmpscr->secretsfx);
4493 }
4494 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4495 {
4496 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4497 {
4498 findentrance(bx,by,mfSWORD+i2,true);
4499 }
4500
4501 findentrance(bx,by,mfSTRIKE,true);
4502 }
4503 else
4504 {
4505 if(isCuttableNextType(type))
4506 {
4507 s->data[i]++;
4508 }
4509 else
4510 {
4511 s->data[i] = s->undercombo;
4512 s->cset[i] = s->undercset;
4513 s->sflag[i] = 0;
4514 }
4515
4516 //pausenow=true;
4517 }
4518 }
4519 else if(skipsecrets && (!ignorescreen || dontignore))
4520 {
4521 if(isCuttableNextType(type))
4522 {
4523 s->data[i]++;
4524 }
4525 else
4526 {
4527 s->data[i] = s->undercombo;
4528 s->cset[i] = s->undercset;
4529 s->sflag[i] = 0;
4530 }
4531 }
4532
4533 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4534 {
4535 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4536 {
4537 findentrance(bx,by,mfSWORD+i2,true);
4538 }
4539
4540 findentrance(fx,fy,mfSTRIKE,true);
4541 }
4542 else if(!ignoreffc)
4543 {
4544 if(isCuttableNextType(type2))
4545 {
4546 s->ffcs[current_ffcombo].incData(1);
4547 }
4548 else
4549 {
4550 s->ffcs[current_ffcombo].setData(s->undercombo);
4551 s->ffcs[current_ffcombo].cset = s->undercset;
4552 }
4553 }
4554
4555 if(!ignorescreen || dontignore)
4556 {
4557 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4558
4559 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4560 {
4561 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4562 sfx(tmpscr->secretsfx);
4563 }
4564 else if(isCuttableItemType(type))
4565 {
4566 int32_t it = -1;
4567 int32_t thedropset = -1;
4568 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4569 {
4570 if ( combobuf[cid].usrflags&cflag11 )
4571 {
4572 it = combobuf[cid].attribytes[1];
4573 }
4574 else
4575 {
4576 it = select_dropitem(combobuf[cid].attribytes[1]);
4577 thedropset = combobuf[cid].attribytes[1];
4578 }
4579 }
4580 else
4581 {
4582 it = select_dropitem(12);
4583 thedropset = 12;
4584 }
4585
4586 if(it!=-1)
4587 {
4588 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4589 itm->from_dropset = thedropset;
4590 items.add(itm);
4591 }
4592 }
4593
4594
4595 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4596
4597 if(get_bit(quest_rules,qr_MORESOUNDS))
4598 {
4599 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4600 {
4601 if (combobuf[cid].usrflags&cflag3)
4602 {
4603 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4604 }
4605 }
4606 else
4607 {
4608 if (combobuf[cid].usrflags&cflag3)
4609 {
4610 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4611 }
4612 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4613 }
4614 }
4615
4616 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4617 if(decotype > 3) decotype = 0;
4618 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4619 switch(decotype)
4620 {
4621 case -2: break; //nothing
4622 case -1:
4623 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4624 break;
4625 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4626 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4627 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4628 }
4629 }
4630
4631 if(!ignoreffc)
4632 {
4633 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4634
4635 if(isCuttableItemType(type2))
4636 {
4637 int32_t it=-1;
4638 int32_t thedropset=-1;
4639 if ( (combobuf[cid].usrflags&cflag2) )
4640 {
4641 if(combobuf[cid].usrflags&cflag11)
4642 it = combobuf[cid].attribytes[1];
4643 else
4644 {
4645 it = select_dropitem(combobuf[cid].attribytes[1]);
4646 thedropset = combobuf[cid].attribytes[1];
4647 }
4648 }
4649 else
4650 {
4651 int32_t r=zc_oldrand()%100;
4652
4653 if(r<15)
4654 {
4655 it=iHeart; // 15%
4656 }
4657 else if(r<35)
4658 {
4659 it=iRupy; // 20%
4660 }
4661 }
4662
4663 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4664 {
4665 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4666 itm->from_dropset = thedropset;
4667 items.add(itm);
4668 }
4669 }
4670
4671 if(get_bit(quest_rules,qr_MORESOUNDS))
4672 {
4673 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4674 {
4675 if (combobuf[cid].usrflags&cflag3)
4676 {
4677 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4678 }
4679 }
4680 else
4681 {
4682 if (combobuf[cid].usrflags&cflag3)
4683 {
4684 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4685 }
4686 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4687 }
4688 }
4689
4690 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4691 if(decotype > 3) decotype = 0;
4692 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4693 switch(decotype)
4694 {
4695 case -2: break; //nothing
4696 case -1:
4697 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4698 break;
4699 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4700 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4701 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4702 }
4703 }
4704 4928744 }
4705
4706 4928744 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4707 {
4708 /*
4709 int32_t par_item = w->parentitem;
4710 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4711 int32_t usewpn = -1;
4712 if ( par_item > -1 )
4713 {
4714 usewpn = itemsbuf[par_item].useweapon;
4715 }
4716 else if ( par_item == -1 && w->ScriptGenerated )
4717 {
4718 usewpn = w->useweapon;
4719 }
4720 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4721 */
4722
4723 4928744 byte dontignore = 0;
4724 4928744 byte dontignoreffc = 0;
4725
4726
4727
4728
4729
4730 //keep things inside the screen boundaries
4731 4928744 bx=vbound(bx, 0, 255);
4732 4928744 by=vbound(by, 0, 176);
4733 4928744 int32_t fx=vbound(bx, 0, 255);
4734 4928744 int32_t fy=vbound(by, 0, 176);
4735 4928744 int32_t cid = MAPCOMBO(bx,by);
4736
4737 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4738
2/4
✓ Branch 0 taken 4928744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4928744 times.
4928744 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4739 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4740
4741 //first things first
4742 if(z>8||fakez>8) return;
4743
4744 //find out which combo row/column the coordinates are in
4745 bx &= 0xF0;
4746 by &= 0xF0;
4747
4748 int32_t flag = MAPFLAG(bx,by);
4749 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4750 int32_t flag3=0;
4751 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4752 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4753 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4754 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4755
4756 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4757 flag3=mfWAND;
4758
4759 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4760 flag3=mfSTRIKE;
4761
4762 int32_t i = (bx>>4) + by;
4763
4764 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4765 return;
4766
4767 if(i > 175)
4768 return;
4769
4770 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4771
4772 //findentrance(bx,by,mfWAND,true);
4773 //findentrance(bx,by,mfSTRIKE,true);
4774 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4775 {
4776 if(flag3==mfWAND||flag3==mfSTRIKE)
4777 {
4778 findentrance(fx,fy,mfWAND,true);
4779 findentrance(fx,fy,mfSTRIKE,true);
4780 }
4781 }
4782
4783 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4784
4785 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4786 4928744 }
4787
4788 4928744 void HeroClass::check_pound_block2(int32_t bx, int32_t by, weapon *w)
4789 {
4790 /*
4791 int32_t par_item = w->parentitem;
4792 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
4793 int32_t usewpn = -1;
4794 if ( par_item > -1 )
4795 {
4796 usewpn = itemsbuf[par_item].useweapon;
4797 }
4798 else if ( par_item == -1 && w->ScriptGenerated )
4799 {
4800 usewpn = w->useweapon;
4801 }
4802 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
4803 */
4804 //keep things inside the screen boundaries
4805 4928744 bx=vbound(bx, 0, 255);
4806 4928744 by=vbound(by, 0, 176);
4807 4928744 int32_t fx=vbound(bx, 0, 255);
4808 4928744 int32_t fy=vbound(by, 0, 176);
4809 4928744 int32_t cid = MAPCOMBO(bx,by);
4810 4928744 byte dontignore = MatchComboTrigger (w, combobuf, cid);
4811
2/4
✓ Branch 0 taken 4928744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4928744 times.
4928744 if(w->useweapon != wHammer && !dontignore ) return;
4812
4813
4814
4815
4816 //first things first
4817 if(z>8||fakez>8) return;
4818
4819 //find out which combo row/column the coordinates are in
4820 bx &= 0xF0;
4821 by &= 0xF0;
4822
4823 int32_t type = COMBOTYPE(bx,by);
4824 int32_t type2 = FFCOMBOTYPE(fx,fy);
4825 int32_t flag = MAPFLAG(bx,by);
4826 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4827 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4828 int32_t i = (bx>>4) + by;
4829 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4830
4831 if(i > 175)
4832 return;
4833
4834 bool ignorescreen=false;
4835 bool ignoreffc=false;
4836 bool pound=false;
4837
4838 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4839 type = cNONE;
4840 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
4841 ignorescreen = true; // Affect only FFCs
4842
4843 if(get_bit(w->wscreengrid, i) != 0)
4844 {
4845 ignorescreen = true; dontignore = 0;
4846 }
4847
4848 int32_t current_ffcombo = getFFCAt(fx,fy);
4849
4850 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4851 ignoreffc = true;
4852 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4853 type2 = cNONE;
4854 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
4855 ignoreffc = true;
4856
4857 if(ignorescreen && ignoreffc) // Nothing to do.
4858 return;
4859
4860 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4861
4862 if(!ignorescreen || dontignore)
4863 {
4864 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
4865 {
4866 findentrance(bx,by,mfHAMMER,true);
4867 findentrance(bx,by,mfSTRIKE,true);
4868 }
4869 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
4870 {
4871 findentrance(bx,by,mfHAMMER,true);
4872 findentrance(bx,by,mfSTRIKE,true);
4873 }
4874 else if((flag >= 16)&&(flag <= 31))
4875 {
4876 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4877 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4878 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4879 }
4880 else if(flag == mfARMOS_SECRET)
4881 {
4882 s->data[i] = s->secretcombo[sSTAIRS];
4883 s->cset[i] = s->secretcset[sSTAIRS];
4884 s->sflag[i] = s->secretflag[sSTAIRS];
4885 sfx(tmpscr->secretsfx);
4886 }
4887 else if((flag2 >= 16)&&(flag2 <= 31))
4888 {
4889 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4890 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4891 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4892 }
4893 else if(flag2 == mfARMOS_SECRET)
4894 {
4895 s->data[i] = s->secretcombo[sSTAIRS];
4896 s->cset[i] = s->secretcset[sSTAIRS];
4897 s->sflag[i] = s->secretflag[sSTAIRS];
4898 sfx(tmpscr->secretsfx);
4899 }
4900 else pound = true;
4901 }
4902
4903 if(!ignoreffc)
4904 {
4905 if(flag3==mfHAMMER||flag3==mfSTRIKE)
4906 {
4907 findentrance(fx,fy,mfHAMMER,true);
4908 findentrance(fx,fy,mfSTRIKE,true);
4909 }
4910 else
4911 {
4912 s->ffcs[current_ffcombo].incData(1);
4913 }
4914 }
4915
4916 if(!ignorescreen || dontignore)
4917 {
4918 if(pound)
4919 s->data[i]+=1;
4920
4921 set_bit(w->wscreengrid,i,1);
4922
4923 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4924 {
4925 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4926 sfx(tmpscr->secretsfx);
4927 }
4928
4929 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4930 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4931
4932 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4933 }
4934
4935 if(!ignoreffc)
4936 {
4937 set_bit(ffcgrid,current_ffcombo,1);
4938
4939 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4940 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4941 }
4942
4943 return;
4944 4928744 }
4945
4946 void HeroClass::check_slash_block(weapon *w)
4947 {
4948 //first things
4949
4950 int32_t par_item = w->parentitem;
4951 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4952 int32_t usewpn = -1;
4953 if ( par_item > -1 )
4954 {
4955 usewpn = itemsbuf[par_item].useweapon;
4956 }
4957 else if ( par_item == -1 && w->ScriptGenerated )
4958 {
4959 usewpn = w->useweapon;
4960 }
4961 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4962 if(usewpn != wSword) return;
4963
4964
4965 int32_t bx = 0, by = 0;
4966 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
4967 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
4968 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4969 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4970 //keep things inside the screen boundaries
4971 bx=vbound(bx, 0, 255);
4972 by=vbound(by, 0, 176);
4973 int32_t fx=vbound(bx, 0, 255);
4974 int32_t fy=vbound(by, 0, 176);
4975
4976 int32_t cid = MAPCOMBO(bx,by);
4977
4978 //find out which combo row/column the coordinates are in
4979 bx &= 0xF0;
4980 by &= 0xF0;
4981
4982 int32_t type = COMBOTYPE(bx,by);
4983 int32_t type2 = FFCOMBOTYPE(fx,fy);
4984 int32_t flag = MAPFLAG(bx,by);
4985 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4986 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4987 int32_t i = (bx>>4) + by;
4988
4989 if(i > 175)
4990 {
4991 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4992 return;
4993 }
4994
4995 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4996 type = cNONE;
4997 bool ignorescreen=false;
4998 bool ignoreffc=false;
4999
5000 if(get_bit(screengrid, i) != 0)
5001 {
5002 ignorescreen = true;
5003 }
5004
5005 int32_t current_ffcombo = getFFCAt(fx,fy);
5006
5007 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5008 {
5009 ignoreffc = true;
5010 }
5011 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
5012 type2 = cNONE;
5013 if(!isCuttableType(type) &&
5014 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5015 {
5016 ignorescreen = true;
5017 }
5018
5019 if(!isCuttableType(type2) &&
5020 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5021 {
5022 ignoreffc = true;
5023 }
5024
5025 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5026
5027 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5028
5029 if(!ignorescreen)
5030 {
5031 if((flag >= 16)&&(flag <= 31))
5032 {
5033 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5034 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5035 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5036 }
5037 else if(flag == mfARMOS_SECRET)
5038 {
5039 s->data[i] = s->secretcombo[sSTAIRS];
5040 s->cset[i] = s->secretcset[sSTAIRS];
5041 s->sflag[i] = s->secretflag[sSTAIRS];
5042 sfx(tmpscr->secretsfx);
5043 }
5044 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5045 {
5046 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5047 {
5048 findentrance(bx,by,mfSWORD+i2,true);
5049 }
5050
5051 findentrance(bx,by,mfSTRIKE,true);
5052 }
5053 else if(((flag2 >= 16)&&(flag2 <= 31)))
5054 {
5055 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5056 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5057 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5058 }
5059 else if(flag2 == mfARMOS_SECRET)
5060 {
5061 s->data[i] = s->secretcombo[sSTAIRS];
5062 s->cset[i] = s->secretcset[sSTAIRS];
5063 s->sflag[i] = s->secretflag[sSTAIRS];
5064 sfx(tmpscr->secretsfx);
5065 }
5066 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5067 {
5068 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5069 {
5070 findentrance(bx,by,mfSWORD+i2,true);
5071 }
5072
5073 findentrance(bx,by,mfSTRIKE,true);
5074 }
5075 else
5076 {
5077 if(isCuttableNextType(type))
5078 {
5079 s->data[i]++;
5080 }
5081 else
5082 {
5083 s->data[i] = s->undercombo;
5084 s->cset[i] = s->undercset;
5085 s->sflag[i] = 0;
5086 }
5087
5088 //pausenow=true;
5089 }
5090 }
5091
5092 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5093 {
5094 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5095 {
5096 findentrance(bx,by,mfSWORD+i2,true);
5097 }
5098
5099 findentrance(fx,fy,mfSTRIKE,true);
5100 }
5101 else if(!ignoreffc)
5102 {
5103 if(isCuttableNextType(type2))
5104 {
5105 s->ffcs[current_ffcombo].incData(1);
5106 }
5107 else
5108 {
5109 s->ffcs[current_ffcombo].setData(s->undercombo);
5110 s->ffcs[current_ffcombo].cset = s->undercset;
5111 }
5112 }
5113
5114 if(!ignorescreen)
5115 {
5116 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5117
5118 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5119 {
5120 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5121 sfx(tmpscr->secretsfx);
5122 }
5123 else if(isCuttableItemType(type))
5124 {
5125 int32_t it = -1;
5126 int32_t thedropset = -1;
5127 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5128 {
5129 if ( combobuf[cid].usrflags&cflag11 )
5130 {
5131 it = combobuf[cid].attribytes[1];
5132 }
5133 else
5134 {
5135 it = select_dropitem(combobuf[cid].attribytes[1]);
5136 thedropset = combobuf[cid].attribytes[1];
5137 }
5138 }
5139 else
5140 {
5141 it = select_dropitem(12);
5142 thedropset = 12;
5143 }
5144
5145 if(it!=-1)
5146 {
5147 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5148 itm->from_dropset = thedropset;
5149 items.add(itm);
5150 }
5151 }
5152
5153 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5154
5155 if(get_bit(quest_rules,qr_MORESOUNDS))
5156 {
5157 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5158 {
5159 if (combobuf[cid].usrflags&cflag3)
5160 {
5161 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5162 }
5163 }
5164 else
5165 {
5166 if (combobuf[cid].usrflags&cflag3)
5167 {
5168 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5169 }
5170 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5171 }
5172 }
5173
5174 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5175 if(decotype > 3) decotype = 0;
5176 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5177 switch(decotype)
5178 {
5179 case -2: break; //nothing
5180 case -1:
5181 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5182 break;
5183 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5184 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5185 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5186 }
5187 }
5188
5189 if(!ignoreffc)
5190 {
5191 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5192
5193 if(isCuttableItemType(type2))
5194 {
5195 int32_t it=-1;
5196 int32_t thedropset = -1;
5197 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5198 {
5199 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5200 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5201 else
5202 {
5203 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5204 it = select_dropitem(thedropset);
5205 }
5206 }
5207 else
5208 {
5209 it = select_dropitem(12);
5210 thedropset = 12;
5211 }
5212
5213 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5214 {
5215 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5216 itm->from_dropset = thedropset;
5217 items.add(itm);
5218 }
5219 }
5220
5221 if(get_bit(quest_rules,qr_MORESOUNDS))
5222 {
5223 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5224 {
5225 if (combobuf[cid].usrflags&cflag3)
5226 {
5227 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5228 }
5229 }
5230 else
5231 {
5232 if (combobuf[cid].usrflags&cflag3)
5233 {
5234 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5235 }
5236 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5237 }
5238 }
5239
5240 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5241 if(decotype > 3) decotype = 0;
5242 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5243 switch(decotype)
5244 {
5245 case -2: break; //nothing
5246 case -1:
5247 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5248 break;
5249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5250 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5251 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5252 }
5253 }
5254 }
5255
5256 //TODO: Boomerang that cuts bushes. -L
5257 /*void HeroClass::slash_bush()
5258 {
5259
5260 }*/
5261
5262 12336 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5263 {
5264 //keep things inside the screen boundaries
5265 12336 bx=vbound(bx, 0, 255);
5266 12336 by=vbound(by, 0, 176);
5267 12336 int32_t fx=vbound(bx, 0, 255);
5268 12336 int32_t fy=vbound(by, 0, 176);
5269 12336 int32_t cid = MAPCOMBO(bx,by);
5270
5271 //first things first
5272
2/4
✓ Branch 0 taken 12336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12336 times.
12336 if(z>8||fakez>8) return;
5273
5274 //find out which combo row/column the coordinates are in
5275 12336 bx &= 0xF0;
5276 12336 by &= 0xF0;
5277
5278 12336 int32_t flag = MAPFLAG(bx,by);
5279 12336 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5280 12336 int32_t flag3=0;
5281 12336 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5282 12336 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5283 12336 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5284 12336 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5285
5286
4/8
✓ Branch 0 taken 12336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12336 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12336 times.
12336 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5287 flag3=mfWAND;
5288
5289
4/8
✓ Branch 0 taken 12336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12336 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12336 times.
12336 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5290 flag3=mfSTRIKE;
5291
5292 12336 int32_t i = (bx>>4) + by;
5293
5294
6/12
✓ Branch 0 taken 12336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12336 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12336 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12336 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12336 times.
✗ Branch 11 not taken.
12336 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5295 12336 return;
5296
5297 if(i > 175)
5298 return;
5299
5300 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5301
5302 //findentrance(bx,by,mfWAND,true);
5303 //findentrance(bx,by,mfSTRIKE,true);
5304 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5305 {
5306 if(flag3==mfWAND||flag3==mfSTRIKE)
5307 {
5308 findentrance(fx,fy,mfWAND,true);
5309 findentrance(fx,fy,mfSTRIKE,true);
5310 }
5311 }
5312
5313 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5314 12336 }
5315
5316 void HeroClass::check_pound_block(int32_t bx, int32_t by)
5317 {
5318 //keep things inside the screen boundaries
5319 bx=vbound(bx, 0, 255);
5320 by=vbound(by, 0, 176);
5321 int32_t fx=vbound(bx, 0, 255);
5322 int32_t fy=vbound(by, 0, 176);
5323 int32_t cid = MAPCOMBO(bx,by);
5324
5325 //first things first
5326 if(z>8||fakez>8) return;
5327
5328 //find out which combo row/column the coordinates are in
5329 bx &= 0xF0;
5330 by &= 0xF0;
5331
5332 int32_t type = COMBOTYPE(bx,by);
5333 int32_t type2 = FFCOMBOTYPE(fx,fy);
5334 int32_t flag = MAPFLAG(bx,by);
5335 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5336 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5337 int32_t i = (bx>>4) + by;
5338
5339 if(i > 175)
5340 return;
5341
5342 bool ignorescreen=false;
5343 bool ignoreffc=false;
5344 bool pound=false;
5345
5346 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5347 ignorescreen = true; // Affect only FFCs
5348
5349 if(get_bit(screengrid, i) != 0)
5350 ignorescreen = true;
5351
5352 int32_t current_ffcombo = getFFCAt(fx,fy);
5353
5354 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5355 ignoreffc = true;
5356
5357 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5358 ignoreffc = true;
5359
5360 if(ignorescreen && ignoreffc) // Nothing to do.
5361 return;
5362
5363 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5364
5365 if(!ignorescreen)
5366 {
5367 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5368 {
5369 findentrance(bx,by,mfHAMMER,true);
5370 findentrance(bx,by,mfSTRIKE,true);
5371 }
5372 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5373 {
5374 findentrance(bx,by,mfHAMMER,true);
5375 findentrance(bx,by,mfSTRIKE,true);
5376 }
5377 else if((flag >= 16)&&(flag <= 31))
5378 {
5379 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5380 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5381 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5382 }
5383 else if(flag == mfARMOS_SECRET)
5384 {
5385 s->data[i] = s->secretcombo[sSTAIRS];
5386 s->cset[i] = s->secretcset[sSTAIRS];
5387 s->sflag[i] = s->secretflag[sSTAIRS];
5388 sfx(tmpscr->secretsfx);
5389 }
5390 else if((flag2 >= 16)&&(flag2 <= 31))
5391 {
5392 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5393 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5394 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5395 }
5396 else if(flag2 == mfARMOS_SECRET)
5397 {
5398 s->data[i] = s->secretcombo[sSTAIRS];
5399 s->cset[i] = s->secretcset[sSTAIRS];
5400 s->sflag[i] = s->secretflag[sSTAIRS];
5401 sfx(tmpscr->secretsfx);
5402 }
5403 else pound = true;
5404 }
5405
5406 if(!ignoreffc)
5407 {
5408 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5409 {
5410 findentrance(fx,fy,mfHAMMER,true);
5411 findentrance(fx,fy,mfSTRIKE,true);
5412 }
5413 else
5414 {
5415 s->ffcs[current_ffcombo].incData(1);
5416 }
5417 }
5418
5419 if(!ignorescreen)
5420 {
5421 if(pound)
5422 s->data[i]+=1;
5423
5424 set_bit(screengrid,i,1);
5425
5426 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5427 {
5428 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5429 sfx(tmpscr->secretsfx);
5430 }
5431
5432 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5433 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5434
5435 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5436 }
5437
5438 if(!ignoreffc)
5439 {
5440 set_bit(ffcgrid,current_ffcombo,1);
5441
5442 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5443 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5444 }
5445
5446 return;
5447 }
5448
5449
5450 void HeroClass::check_wand_block(weapon *w)
5451 {
5452
5453 int32_t par_item = w->parentitem;
5454 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5455 int32_t usewpn = -1;
5456 if ( par_item > -1 )
5457 {
5458 usewpn = itemsbuf[par_item].useweapon;
5459 }
5460 else if ( par_item == -1 && w->ScriptGenerated )
5461 {
5462 usewpn = w->useweapon;
5463 }
5464 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5465 if(usewpn != wWand) return;
5466
5467
5468 int32_t bx = 0, by = 0;
5469 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5470 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5471
5472 //keep things inside the screen boundaries
5473 bx=vbound(bx, 0, 255);
5474 by=vbound(by, 0, 176);
5475 int32_t fx=vbound(bx, 0, 255);
5476 int32_t fy=vbound(by, 0, 176);
5477 int32_t cid = MAPCOMBO(bx,by);
5478 //first things first
5479 if(z>8||fakez>8) return;
5480
5481 //find out which combo row/column the coordinates are in
5482 bx &= 0xF0;
5483 by &= 0xF0;
5484
5485 int32_t flag = MAPFLAG(bx,by);
5486 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5487 int32_t flag3=0;
5488 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5489 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5490 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5491 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5492
5493 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5494 flag3=mfWAND;
5495
5496 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5497 flag3=mfSTRIKE;
5498
5499 int32_t i = (bx>>4) + by;
5500
5501 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5502 return;
5503
5504 if(i > 175)
5505 return;
5506
5507 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5508
5509 //findentrance(bx,by,mfWAND,true);
5510 //findentrance(bx,by,mfSTRIKE,true);
5511 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5512 {
5513 if(flag3==mfWAND||flag3==mfSTRIKE)
5514 {
5515 findentrance(fx,fy,mfWAND,true);
5516 findentrance(fx,fy,mfSTRIKE,true);
5517 }
5518 }
5519
5520 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5521 }
5522
5523 void HeroClass::check_pound_block(weapon *w)
5524 {
5525
5526 int32_t par_item = w->parentitem;
5527 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
5528 int32_t usewpn = -1;
5529 if ( par_item > -1 )
5530 {
5531 usewpn = itemsbuf[par_item].useweapon;
5532 }
5533 else if ( par_item == -1 && w->ScriptGenerated )
5534 {
5535 usewpn = w->useweapon;
5536 }
5537 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
5538 if(usewpn != wHammer) return;
5539
5540
5541 int32_t bx = 0, by = 0;
5542 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5543 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5544 //keep things inside the screen boundaries
5545 bx=vbound(bx, 0, 255);
5546 by=vbound(by, 0, 176);
5547 int32_t fx=vbound(bx, 0, 255);
5548 int32_t fy=vbound(by, 0, 176);
5549 int32_t cid = MAPCOMBO(bx,by);
5550 //first things first
5551 if(z>8||fakez>8) return;
5552
5553 //find out which combo row/column the coordinates are in
5554 bx &= 0xF0;
5555 by &= 0xF0;
5556
5557 int32_t type = COMBOTYPE(bx,by);
5558 int32_t type2 = FFCOMBOTYPE(fx,fy);
5559 int32_t flag = MAPFLAG(bx,by);
5560 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5561 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5562 int32_t i = (bx>>4) + by;
5563
5564 if(i > 175)
5565 return;
5566
5567 bool ignorescreen=false;
5568 bool ignoreffc=false;
5569 bool pound=false;
5570
5571 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5572 ignorescreen = true; // Affect only FFCs
5573
5574 if(get_bit(screengrid, i) != 0)
5575 ignorescreen = true;
5576
5577 int32_t current_ffcombo = getFFCAt(fx,fy);
5578
5579 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5580 ignoreffc = true;
5581
5582 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5583 ignoreffc = true;
5584
5585 if(ignorescreen && ignoreffc) // Nothing to do.
5586 return;
5587
5588 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5589
5590 if(!ignorescreen)
5591 {
5592 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5593 {
5594 findentrance(bx,by,mfHAMMER,true);
5595 findentrance(bx,by,mfSTRIKE,true);
5596 }
5597 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5598 {
5599 findentrance(bx,by,mfHAMMER,true);
5600 findentrance(bx,by,mfSTRIKE,true);
5601 }
5602 else if((flag >= 16)&&(flag <= 31))
5603 {
5604 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5605 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5606 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5607 }
5608 else if(flag == mfARMOS_SECRET)
5609 {
5610 s->data[i] = s->secretcombo[sSTAIRS];
5611 s->cset[i] = s->secretcset[sSTAIRS];
5612 s->sflag[i] = s->secretflag[sSTAIRS];
5613 sfx(tmpscr->secretsfx);
5614 }
5615 else if((flag2 >= 16)&&(flag2 <= 31))
5616 {
5617 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5618 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5619 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5620 }
5621 else if(flag2 == mfARMOS_SECRET)
5622 {
5623 s->data[i] = s->secretcombo[sSTAIRS];
5624 s->cset[i] = s->secretcset[sSTAIRS];
5625 s->sflag[i] = s->secretflag[sSTAIRS];
5626 sfx(tmpscr->secretsfx);
5627 }
5628 else pound = true;
5629 }
5630
5631 if(!ignoreffc)
5632 {
5633 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5634 {
5635 findentrance(fx,fy,mfHAMMER,true);
5636 findentrance(fx,fy,mfSTRIKE,true);
5637 }
5638 else
5639 {
5640 s->ffcs[current_ffcombo].incData(1);
5641 }
5642 }
5643
5644 if(!ignorescreen)
5645 {
5646 if(pound)
5647 s->data[i]+=1;
5648
5649 set_bit(screengrid,i,1);
5650
5651 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5652 {
5653 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5654 sfx(tmpscr->secretsfx);
5655 }
5656
5657 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5658 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5659
5660 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5661 }
5662
5663 if(!ignoreffc)
5664 {
5665 set_bit(ffcgrid,current_ffcombo,1);
5666
5667 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5668 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5669 }
5670
5671 return;
5672 }
5673
5674 //defend results should match defence types.
5675 //RETURN VALUES:
5676 // -1 iGNORE WEAPON
5677 // 0 No effects
5678 // 1 Effects, weapon is not ignored or removed
5679 3556 int32_t HeroClass::defend(weapon *w)
5680 {
5681 3556 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5682
1/25
✓ Branch 0 taken 3556 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
3556 switch(def)
5683 {
5684 3556 case edNORMAL: return 1;
5685 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5686 {
5687 w->power *= 0.5;
5688 return 1;
5689 }
5690 case edQUARTDAMAGE:
5691 {
5692 w->power *= 0.25;
5693 return 1;
5694 }
5695 case edSTUNONLY:
5696 {
5697 setStunClock(120);
5698 return 1;
5699 }
5700 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5701 {
5702 if (w->power > 0)
5703 {
5704 setStunClock(120);
5705 return 1;
5706 }
5707 else
5708 {
5709 sfx(WAV_CHINK,pan(int32_t(x)));
5710 w->dead = 0;
5711 return -1;
5712 }
5713 }
5714 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5715 {
5716 if (w->power > 0)
5717 {
5718 setStunClock(120);
5719 return 1;
5720 }
5721 else
5722 {
5723 return -1;
5724 }
5725 }
5726 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5727 {
5728 if (w->power < 1)
5729 {
5730 sfx(WAV_CHINK,pan(int32_t(x)));
5731 w->dead = 0;
5732 return -1;
5733 }
5734 else
5735 {
5736 return 1;
5737 }
5738 }
5739 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5740 {
5741 if (w->power < 2)
5742 {
5743 sfx(WAV_CHINK,pan(int32_t(x)));
5744 w->dead = 0;
5745 return -1;
5746 }
5747 else
5748 {
5749 return 1;
5750 }
5751 }
5752 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5753 {
5754 if (w->power < 4)
5755 {
5756 sfx(WAV_CHINK,pan(int32_t(x)));
5757 w->dead = 0;
5758 return -1;
5759 }
5760 else
5761 {
5762 return 1;
5763 }
5764 }
5765 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5766 {
5767 if (w->power < 6)
5768 {
5769 sfx(WAV_CHINK,pan(int32_t(x)));
5770 w->dead = 0;
5771 return -1;
5772 }
5773 else
5774 {
5775 return 1;
5776 }
5777 }
5778 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5779 {
5780 if (w->power < 8)
5781 {
5782 sfx(WAV_CHINK,pan(int32_t(x)));
5783 w->dead = 0;
5784 return -1;
5785 }
5786 else
5787 {
5788 return 1;
5789 }
5790 }
5791 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5792 {
5793 sfx(WAV_CHINK,pan(int32_t(x)));
5794 w->dead = 0;
5795 return -1;
5796 }
5797 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5798 {
5799 if (w->power < 1)
5800 {
5801 return -1;
5802 }
5803 else return 1;
5804 }
5805 case edIGNORE: // : IMPLEMENTED : Do Nothing
5806 {
5807 return -1;
5808 }
5809 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5810 {
5811 game->set_life(0);
5812 return 1;
5813 }
5814 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5815 {
5816 if (w->power < 10)
5817 {
5818 sfx(WAV_CHINK,pan(int32_t(x)));
5819 w->dead = 0;
5820 return -1;
5821 }
5822 else
5823 {
5824 return 1;
5825 }
5826 }
5827 case ed2x: // : IMPLEMENTED : Double damage.
5828 {
5829 w->power *= 2;
5830 return 1;
5831 }
5832 case ed3x: // : IMPLEMENTED : Triple Damage.
5833 {
5834 w->power *= 3;
5835 return 1;
5836 }
5837 case ed4x: // : IMPLEMENTED : 4x damage.
5838 {
5839 w->power *= 4;
5840 return 1;
5841 }
5842 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5843 {
5844 //sfx(WAV_HEAL,pan(int32_t(x)));
5845 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5846 w->dead = 0;
5847 return -1;
5848 }
5849
5850 case edFREEZE: return 1; //Not IMPLEMENTED
5851
5852 case edLEVELDAMAGE: //Damage * item level
5853 {
5854 w->power *= w->family_level;
5855 return 1;
5856 }
5857 case edLEVELREDUCTION: //Damage / item level
5858 {
5859 if ( w->family_level > 0 )
5860 {
5861 w->power /= w->family_level;
5862 }
5863 else w->power = 0;
5864 return 1;
5865 }
5866
5867 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5868 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5869 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5870 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5871
5872 //edSHOCK, //buzz blob
5873
5874
5875 case edBREAKSHIELD: //destroy the player's present shield
5876 {
5877 w->power = 0;
5878 w->dead = 0;
5879 int32_t itemid = getCurrentShield();
5880 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5881 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5882 game->set_item(itemid, false);
5883 //Remove Hero's shield
5884 return -1;
5885 }
5886
5887
5888
5889 default: return 0;
5890 }
5891 3556 }
5892
5893 3552 int32_t HeroClass::compareDir(int32_t other)
5894 {
5895
5/6
✓ Branch 0 taken 3547 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3547 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 3550 times.
3552 if(other != NORMAL_DIR(other))
5896 2 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5897 3550 int32_t ret = 0;
5898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3550 times.
3550 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5899
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
✓ Branch 2 taken 599 times.
✓ Branch 3 taken 1193 times.
✓ Branch 4 taken 1137 times.
3550 switch(d)
5900 {
5901 case up:
5902 {
5903
3/3
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 245 times.
621 switch(X_DIR(other))
5904 {
5905 case left:
5906 246 ret |= CMPDIR_RIGHT;
5907 246 break;
5908 case right:
5909 245 ret |= CMPDIR_LEFT;
5910 245 break;
5911 }
5912
3/3
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 424 times.
621 switch(Y_DIR(other))
5913 {
5914 case up:
5915 139 ret |= CMPDIR_BACK;
5916 139 break;
5917 case down:
5918 424 ret |= CMPDIR_FRONT;
5919 424 break;
5920 }
5921 621 break;
5922 }
5923 case down:
5924 {
5925
3/3
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 191 times.
✓ Branch 2 taken 262 times.
599 switch(X_DIR(other))
5926 {
5927 case left:
5928 191 ret |= CMPDIR_LEFT;
5929 191 break;
5930 case right:
5931 262 ret |= CMPDIR_RIGHT;
5932 262 break;
5933 }
5934
3/3
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 414 times.
✓ Branch 2 taken 110 times.
599 switch(Y_DIR(other))
5935 {
5936 case up:
5937 414 ret |= CMPDIR_FRONT;
5938 414 break;
5939 case down:
5940 110 ret |= CMPDIR_BACK;
5941 110 break;
5942 }
5943 599 break;
5944 }
5945 case left:
5946 {
5947
3/3
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 173 times.
✓ Branch 2 taken 974 times.
1193 switch(X_DIR(other))
5948 {
5949 case left:
5950 173 ret |= CMPDIR_BACK;
5951 173 break;
5952 case right:
5953 974 ret |= CMPDIR_FRONT;
5954 974 break;
5955 }
5956
3/3
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 384 times.
✓ Branch 2 taken 386 times.
1193 switch(Y_DIR(other))
5957 {
5958 case up:
5959 384 ret |= CMPDIR_LEFT;
5960 384 break;
5961 case down:
5962 386 ret |= CMPDIR_RIGHT;
5963 386 break;
5964 }
5965 1193 break;
5966 }
5967 case right:
5968 {
5969
3/3
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 934 times.
✓ Branch 2 taken 162 times.
1137 switch(X_DIR(other))
5970 {
5971 case left:
5972 934 ret |= CMPDIR_FRONT;
5973 934 break;
5974 case right:
5975 162 ret |= CMPDIR_BACK;
5976 162 break;
5977 }
5978
3/3
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 319 times.
✓ Branch 2 taken 435 times.
1137 switch(Y_DIR(other))
5979 {
5980 case up:
5981 319 ret |= CMPDIR_RIGHT;
5982 319 break;
5983 case down:
5984 435 ret |= CMPDIR_LEFT;
5985 435 break;
5986 }
5987 1137 break;
5988 }
5989 }
5990 3550 return ret;
5991 3552 }
5992
5993 3552 bool compareShield(int32_t cmpdir, itemdata const& shield)
5994 {
5995
1/2
✓ Branch 0 taken 3552 times.
✗ Branch 1 not taken.
3552 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5996
1/2
✓ Branch 0 taken 3552 times.
✗ Branch 1 not taken.
3552 if(standard) //Use standard sides, either a passive shield, or a held active shield
5997 {
5998
3/4
✓ Branch 0 taken 2746 times.
✓ Branch 1 taken 806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2746 times.
3552 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5999 2746 return true;
6000
3/4
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 584 times.
✗ Branch 3 not taken.
806 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
6001 return true;
6002
3/4
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
806 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
6003 return true;
6004
3/4
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 370 times.
806 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
6005 return true;
6006 806 }
6007 else //Active Shield that is NOT held down
6008 {
6009 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
6010 return true;
6011 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
6012 return true;
6013 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
6014 return true;
6015 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
6016 return true;
6017 }
6018 806 return false;
6019 3552 }
6020
6021 2161244 int32_t HeroClass::EwpnHit()
6022 {
6023
2/2
✓ Branch 0 taken 2159787 times.
✓ Branch 1 taken 2358667 times.
4518454 for(int32_t i=0; i<Ewpns.Count(); i++)
6024 {
6025
2/2
✓ Branch 0 taken 2355111 times.
✓ Branch 1 taken 3556 times.
2358667 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6026 {
6027 3556 weapon *ew = (weapon*)(Ewpns.spr(i));
6028
6029
3/6
✓ Branch 0 taken 3556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3556 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3556 times.
3556 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6030 break;
6031
6032 3556 int32_t stompid = current_item_id(itype_stompboots);
6033
6034
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3556 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6035 ((z+fakez) > (ew->z+(ew->fakez))) ||
6036 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6037 {
6038 itemdata const& stomp = itemsbuf[stompid];
6039 bool remove = false;
6040 switch(ew->id)
6041 {
6042 case ewFireball2:
6043 case ewFireball:
6044 if(ew->type & 1) //Boss fireball
6045 {
6046 if(stomp.misc2 & (shFIREBALL2))
6047 remove = true;
6048 }
6049 else
6050 {
6051 if(stomp.misc2 & (shFIREBALL))
6052 remove = true;
6053 }
6054
6055 break;
6056
6057 case ewMagic:
6058 if((stomp.misc2 & shMAGIC))
6059 remove = true;
6060 break;
6061
6062 case ewSword:
6063 if((stomp.misc2 & shSWORD))
6064 remove = true;
6065
6066 break;
6067
6068 case ewFlame:
6069 if((stomp.misc2 & shFLAME))
6070 remove = true;
6071
6072 break;
6073
6074 case ewRock:
6075 if((stomp.misc2 & shROCK))
6076 remove = true;
6077
6078 break;
6079
6080 case ewArrow:
6081 if((stomp.misc2 & shARROW))
6082 remove = true;
6083
6084 break;
6085
6086 case ewBrang:
6087 if((stomp.misc2 & shBRANG))
6088 remove = true;
6089
6090 break;
6091
6092 default: // Just throw the script weapons in here...
6093 if(ew->id>=wScript1 && ew->id<=wScript10)
6094 {
6095 if((stomp.misc2 & shSCRIPT))
6096 remove = true;
6097 }
6098
6099 break;
6100 }
6101 if (remove)
6102 {
6103 ew->onhit(false);
6104 sfx(WAV_CHINK,pan(x.getInt()));
6105 continue;
6106 }
6107 }
6108
6109 3556 int32_t defresult = defend(ew);
6110
1/2
✓ Branch 0 taken 3556 times.
✗ Branch 1 not taken.
3556 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6111
6112
2/2
✓ Branch 0 taken 3555 times.
✓ Branch 1 taken 1 times.
3556 if(ew->id==ewWind)
6113 {
6114 1 xofs=1000;
6115 1 action=freeze; FFCore.setHeroAction(freeze);
6116 1 ew->misc=999; // in enemy wind
6117 1 attackclk=0;
6118 1 return -1;
6119 }
6120
6121
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3552 times.
3555 switch(ew->id)
6122 {
6123 case ewLitBomb:
6124 case ewBomb:
6125 case ewLitSBomb:
6126 case ewSBomb:
6127 3 return i;
6128 }
6129
6130 3552 int32_t itemid = getCurrentShield(false);
6131
3/6
✓ Branch 0 taken 3552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3552 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3552 times.
3552 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6132 3552 itemdata const& shield = itemsbuf[itemid];
6133 3552 auto cmpdir = compareDir(ew->dir);
6134 3552 bool hitshield = compareShield(cmpdir, shield);
6135
6136
6137
12/18
✓ Branch 0 taken 2746 times.
✓ Branch 1 taken 806 times.
✓ Branch 2 taken 2249 times.
✓ Branch 3 taken 497 times.
✓ Branch 4 taken 2249 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2248 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 2248 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2248 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2248 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2248 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2248 times.
3552 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF)
6138 {
6139 1304 return i;
6140 }
6141
6142 2248 paymagiccost(itemid);
6143
6144 2248 bool reflect = false;
6145
6146
7/8
✓ Branch 0 taken 1417 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 178 times.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 99 times.
✓ Branch 7 taken 81 times.
2248 switch(ew->id)
6147 {
6148 case ewFireball2:
6149 case ewFireball:
6150
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 1327 times.
1417 if(ew->type & 1) //Boss fireball
6151 {
6152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(!(shield.misc1 & (shFIREBALL2)))
6153 90 return i;
6154
6155 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6156 }
6157 else
6158 {
6159
2/2
✓ Branch 0 taken 1292 times.
✓ Branch 1 taken 35 times.
1327 if(!(shield.misc1 & (shFIREBALL)))
6160 35 return i;
6161
6162 1292 reflect = ((shield.misc2 & shFIREBALL) != 0);
6163 }
6164
6165 1292 break;
6166
6167 case ewMagic:
6168
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1 times.
291 if(!(shield.misc1 & shMAGIC))
6169 1 return i;
6170
6171 290 reflect = ((shield.misc2 & shMAGIC) != 0);
6172 290 break;
6173
6174 case ewSword:
6175
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 1 times.
178 if(!(shield.misc1 & shSWORD))
6176 1 return i;
6177
6178 177 reflect = ((shield.misc2 & shSWORD) != 0);
6179 177 break;
6180
6181 case ewFlame:
6182
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 22 times.
55 if(!(shield.misc1 & shFLAME))
6183 22 return i;
6184
6185 33 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6186 33 break;
6187
6188 case ewRock:
6189
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!(shield.misc1 & shROCK))
6190 return i;
6191
6192 127 reflect = (shield.misc2 & shROCK);
6193 127 break;
6194
6195 case ewArrow:
6196
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!(shield.misc1 & shARROW))
6197 return i;
6198
6199 99 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6200 99 break;
6201
6202 case ewBrang:
6203
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!(shield.misc1 & shBRANG))
6204 return i;
6205
6206 81 break;
6207
6208 default: // Just throw the script weapons in here...
6209 if(ew->id>=wScript1 && ew->id<=wScript10)
6210 {
6211 if(!(shield.misc1 & shSCRIPT))
6212 return i;
6213
6214 reflect = ((shield.misc2 & shSCRIPT) != 0);
6215 }
6216
6217 break;
6218 }
6219
6220
3/4
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 1615 times.
✓ Branch 2 taken 484 times.
✗ Branch 3 not taken.
2099 if(reflect && (ew->unblockable&WPNUNB_REFL))
6221 reflect = false;
6222
3/4
✓ Branch 0 taken 1615 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 1615 times.
✗ Branch 3 not taken.
2099 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6223 return i;
6224
6225 2099 int32_t oldid = ew->id;
6226 2099 ew->onhit(false, reflect ? 2 : 1, dir);
6227
6228
2/2
✓ Branch 0 taken 1615 times.
✓ Branch 1 taken 484 times.
2099 if(ew->id != oldid) // changed type from ewX to wX
6229 {
6230 // ew->power*=game->get_hero_dmgmult();
6231 484 Lwpns.add(ew);
6232 484 Ewpns.remove(ew);
6233 484 ew->isLWeapon = true; //Make sure this gets set everywhere!
6234 484 }
6235
6236
2/2
✓ Branch 0 taken 1911 times.
✓ Branch 1 taken 188 times.
2099 if(ew->id==wRefMagic)
6237 {
6238 188 ew->ignoreHero=true;
6239 188 ew->ignorecombo=-1;
6240 188 }
6241
6242 2099 sfx(shield.usesound,pan(x.getInt()));
6243 2099 }
6244 2357210 }
6245
6246 2159787 return -1;
6247 2161244 }
6248
6249 2161244 int32_t HeroClass::LwpnHit() //only here to check magic hits
6250 {
6251
2/2
✓ Branch 0 taken 2106721 times.
✓ Branch 1 taken 1020669 times.
3127390 for(int32_t i=0; i<Lwpns.Count(); i++)
6252
2/2
✓ Branch 0 taken 966146 times.
✓ Branch 1 taken 54523 times.
1020669 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6253 {
6254 54523 weapon *lw = (weapon*)(Lwpns.spr(i));
6255
6256
2/2
✓ Branch 0 taken 53103 times.
✓ Branch 1 taken 1420 times.
54523 if((lw->ignoreHero)==true)
6257 1420 break;
6258
6259
4/8
✓ Branch 0 taken 53103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53103 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 53103 times.
53103 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6260 int32_t itemid = getCurrentShield(false);
6261 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6262 itemdata const& shield = itemsbuf[itemid];
6263 auto cmpdir = compareDir(lw->dir);
6264 bool hitshield = compareShield(cmpdir, shield);
6265 bool reflect = false;
6266
6267 switch(lw->id)
6268 {
6269 case wRefFireball:
6270 if(itemid<0)
6271 return i;
6272
6273 if(lw->type & 1) //Boss fireball
6274 return i;
6275
6276 if(!(shield.misc1 & (shFIREBALL)))
6277 return i;
6278
6279 reflect = ((shield.misc2 & shFIREBALL) != 0);
6280 break;
6281
6282 case wRefMagic:
6283 if(itemid<0)
6284 return i;
6285
6286 if(!(shield.misc1 & shMAGIC))
6287 return i;
6288
6289 reflect = ((shield.misc2 & shMAGIC) != 0);
6290 break;
6291
6292 case wRefBeam:
6293 if(itemid<0)
6294 return i;
6295
6296 if(!(shield.misc1 & shSWORD))
6297 return i;
6298
6299 reflect = ((shield.misc2 & shSWORD) != 0);
6300 break;
6301
6302 case wRefRock:
6303 if(itemid<0)
6304 return i;
6305
6306 if(!(shield.misc1 & shROCK))
6307 return i;
6308
6309 reflect = (shield.misc2 & shROCK);
6310 break;
6311
6312 default:
6313 return -1;
6314 }
6315
6316 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || hopclk==0xFF)
6317 return i;
6318
6319 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6320
6321 paymagiccost(itemid);
6322
6323 lw->onhit(false, 1+reflect, dir);
6324 lw->ignoreHero=true;
6325 lw->ignorecombo=-1;
6326 sfx(shield.usesound,pan(x.getInt()));
6327 }
6328
6329 2108141 return -1;
6330 2161244 }
6331
6332 4328380 void HeroClass::checkhit()
6333 {
6334
2/2
✓ Branch 0 taken 1886496 times.
✓ Branch 1 taken 2441884 times.
4328380 if(checkhero==true)
6335 {
6336
2/2
✓ Branch 0 taken 152267 times.
✓ Branch 1 taken 2289617 times.
2441884 if(hclk>0)
6337 {
6338 152267 --hclk;
6339 152267 }
6340
6341
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 if(NayrusLoveShieldClk>0)
6342 {
6343 --NayrusLoveShieldClk;
6344
6345 if(NayrusLoveShieldClk == 0 && nayruitem != -1)
6346 {
6347 stop_sfx(itemsbuf[nayruitem].usesound);
6348 stop_sfx(itemsbuf[nayruitem].usesound+1);
6349 nayruitem = -1;
6350 }
6351 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(NayrusLoveShieldClk&0xF00) && nayruitem != -1)
6352 {
6353 stop_sfx(itemsbuf[nayruitem].usesound);
6354 cont_sfx(itemsbuf[nayruitem].usesound+1);
6355 }
6356 }
6357 2441884 }
6358
6359
4/4
✓ Branch 0 taken 2413137 times.
✓ Branch 1 taken 1915243 times.
✓ Branch 2 taken 2411180 times.
✓ Branch 3 taken 1957 times.
4328380 if(hclk<39 && action==gothit)
6360 {
6361 1957 action=none; FFCore.setHeroAction(none);
6362 1957 }
6363
6364
5/6
✓ Branch 0 taken 2413137 times.
✓ Branch 1 taken 1915243 times.
✓ Branch 2 taken 2413133 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2413133 times.
4328380 if(hclk<39 && (action==swimhit || action == sideswimhit))
6365 {
6366 4 SetSwim();
6367 4 }
6368
6369
4/4
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4302822 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 20293 times.
4328380 if(hclk>=40 && action==gothit)
6370 {
6371 20293 int val = check_pitslide();
6372
4/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 20085 times.
✓ Branch 2 taken 20373 times.
✓ Branch 3 taken 20165 times.
20293 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6373 {
6374
2/2
✓ Branch 0 taken 81492 times.
✓ Branch 1 taken 20373 times.
101865 for(int32_t i=0; i<4; i++)
6375 {
6376
5/5
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 16440 times.
✓ Branch 2 taken 20448 times.
✓ Branch 3 taken 20996 times.
✓ Branch 4 taken 23544 times.
81492 switch(hitdir)
6377 {
6378 case up:
6379
6/6
✓ Branch 0 taken 913 times.
✓ Branch 1 taken 15527 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 15247 times.
✓ Branch 4 taken 913 times.
✓ Branch 5 taken 15527 times.
16440 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6380 {
6381 913 action=none; FFCore.setHeroAction(none);
6382 913 }
6383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15527 times.
15527 else if (val == -1) --y;
6384
6385 16440 break;
6386
6387 case down:
6388
6/6
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 19030 times.
✓ Branch 2 taken 1184 times.
✓ Branch 3 taken 17846 times.
✓ Branch 4 taken 1434 times.
✓ Branch 5 taken 19014 times.
20448 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6389 {
6390 1434 action=none; FFCore.setHeroAction(none);
6391 1434 }
6392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19014 times.
19014 else if (val == -1) ++y;
6393
6394 20448 break;
6395
6396 case left:
6397
7/8
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 568 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20428 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 20396 times.
✓ Branch 6 taken 568 times.
✓ Branch 7 taken 20428 times.
20996 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6398 {
6399 568 action=none; FFCore.setHeroAction(none);
6400 568 }
6401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20428 times.
20428 else if (val == -1) --x;
6402
6403 20996 break;
6404
6405 case right:
6406
7/8
✓ Branch 0 taken 22829 times.
✓ Branch 1 taken 715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22829 times.
✓ Branch 4 taken 22797 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 715 times.
✓ Branch 7 taken 22829 times.
23544 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6407 {
6408 715 action=none; FFCore.setHeroAction(none);
6409 715 }
6410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22829 times.
22829 else if (val == -1) ++x;
6411
6412 23544 break;
6413 }
6414 81492 }
6415 20373 }
6416 20453 }
6417
6418
17/20
✓ Branch 0 taken 2292760 times.
✓ Branch 1 taken 2035780 times.
✓ Branch 2 taken 2292760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2289810 times.
✓ Branch 5 taken 2950 times.
✓ Branch 6 taken 2289658 times.
✓ Branch 7 taken 152 times.
✓ Branch 8 taken 2289658 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2289658 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2289525 times.
✓ Branch 13 taken 133 times.
✓ Branch 14 taken 2287877 times.
✓ Branch 15 taken 1648 times.
✓ Branch 16 taken 584 times.
✓ Branch 17 taken 2287293 times.
✓ Branch 18 taken 2185488 times.
✓ Branch 19 taken 2186072 times.
4328540 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6419 {
6420 4226151 return;
6421 }
6422
6423
2/2
✓ Branch 0 taken 3296865 times.
✓ Branch 1 taken 2287255 times.
5584120 for(int32_t i=0; i<Lwpns.Count(); i++)
6424 {
6425 3296865 sprite *s = Lwpns.spr(i);
6426 3296865 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6427 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6428 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6429
13/14
✓ Branch 0 taken 17757 times.
✓ Branch 1 taken 3279108 times.
✓ Branch 2 taken 1093036 times.
✓ Branch 3 taken 2186072 times.
✓ Branch 4 taken 1093036 times.
✓ Branch 5 taken 1093036 times.
✓ Branch 6 taken 1078173 times.
✓ Branch 7 taken 14863 times.
✓ Branch 8 taken 1078173 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34447 times.
✓ Branch 11 taken 1043726 times.
✓ Branch 12 taken 23656 times.
✓ Branch 13 taken 10791 times.
3296865 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6430 {
6431
7/10
✓ Branch 0 taken 1021489 times.
✓ Branch 1 taken 33028 times.
✓ Branch 2 taken 33028 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 17 times.
✓ Branch 7 taken 33011 times.
✓ Branch 8 taken 1054500 times.
✓ Branch 9 taken 17 times.
1054534 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6432
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 (itemid < 0 || itemsbuf[itemid].family!=itype_dinsfire))
6433 {
6434 17 std::vector<int32_t> &ev = FFCore.eventData;
6435 17 ev.clear();
6436 17 ev.push_back(lwpn_dp(i)*10000);
6437 17 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6438 17 ev.push_back(0);
6439 17 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6440 17 ev.push_back(48*10000);
6441 17 ev.push_back(ZSD_LWPN*10000);
6442 17 ev.push_back(s->getUID());
6443
6444 17 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6445 17 int32_t dmg = ev[0]/10000;
6446 17 bool nullhit = ev[2] != 0;
6447
6448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(nullhit) {ev.clear(); return;}
6449
6450 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6451 17 ev[0] = ringpower(dmg)*10000;
6452
6453 17 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6454 17 dmg = ev[0]/10000;
6455 17 int32_t hdir = ev[1]/10000;
6456 17 nullhit = ev[2] != 0;
6457 17 bool nayrulove = ev[3] != 0;
6458 17 int32_t iframes = ev[4] / 10000;
6459 17 ev.clear();
6460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(nullhit) return;
6461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!nayrulove)
6462 {
6463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 game->set_life(zc_max(game->get_life()-dmg,0));
6464 17 }
6465
6466 17 hitdir = hdir;
6467
6468
3/6
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
17 if (action != rafting && action != freeze && action != sideswimfreeze)
6469 {
6470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (IsSideSwim())
6471 {
6472 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6473 }
6474
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 else if (action == swimming || hopclk == 0xFF)
6475 {
6476 action=swimhit; FFCore.setHeroAction(swimhit);
6477 }
6478 else
6479 {
6480 17 action=gothit; FFCore.setHeroAction(gothit);
6481 }
6482 17 }
6483
6484
5/8
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
17 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6485 {
6486 5 spins = charging = attackclk = 0;
6487 5 attack=none;
6488 5 tapping = false;
6489 5 }
6490
6491 17 hclk=iframes;
6492 17 sfx(getHurtSFX(),pan(x.getInt()));
6493 17 return;
6494 }
6495 1054500 }
6496
6497 // check enemy weapons true, 1, -1
6498 //
6499
1/2
✓ Branch 0 taken 1110776 times.
✗ Branch 1 not taken.
1110776 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6500 {
6501 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6502 {
6503 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6504 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6505 itemid = vbound(itemid, 0, MAXITEMS-1);
6506
6507 for(int32_t j=0; j<Ewpns.Count(); j++)
6508 {
6509 sprite *t = Ewpns.spr(j);
6510
6511 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6512 {
6513 bool reflect = false;
6514 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6515 switch(t->id)
6516 {
6517 case ewBrang:
6518 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6519
6520 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6521 goto killweapon;
6522
6523 case ewArrow:
6524 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6525
6526 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6527 goto killweapon;
6528
6529 case ewRock:
6530 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6531
6532 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6533 goto killweapon;
6534
6535 case ewFireball2:
6536 case ewFireball:
6537 {
6538 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6539
6540 if(!(itemsbuf[itemid].misc3 & mask)) break;
6541
6542 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6543 goto killweapon;
6544 }
6545
6546 case ewSword:
6547 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6548
6549 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6550 goto killweapon;
6551
6552 case wRefMagic:
6553 case ewMagic:
6554 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6555
6556 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6557 goto killweapon;
6558
6559 case wScript1:
6560 case wScript2:
6561 case wScript3:
6562 case wScript4:
6563 case wScript5:
6564 case wScript6:
6565 case wScript7:
6566 case wScript8:
6567 case wScript9:
6568 case wScript10:
6569 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6570
6571 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6572 goto killweapon;
6573
6574 case ewLitBomb:
6575 case ewLitSBomb:
6576 killweapon:
6577 ((weapon*)s)->dead=1;
6578 weapon *ew = ((weapon*)t);
6579 int32_t oldid = ew->id;
6580 ew->onhit(true, reflect ? 2 : 1, s->dir);
6581
6582 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6583 {
6584 Lwpns.add(ew);
6585 Ewpns.remove(ew);
6586 ew->isLWeapon = true; //Make sure this gets set everywhere!
6587 }
6588
6589 if(ew->id==wRefMagic)
6590 {
6591 ew->ignoreHero=true;
6592 ew->ignorecombo=-1;
6593 }
6594
6595 break;
6596 }
6597
6598 break;
6599 }
6600 }
6601 }
6602 }
6603
6604
5/6
✓ Branch 0 taken 688380 times.
✓ Branch 1 taken 422396 times.
✓ Branch 2 taken 17757 times.
✓ Branch 3 taken 670623 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17757 times.
1110776 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6605 {
6606
2/10
✓ Branch 0 taken 422396 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 422396 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
422396 if(((s->id==wBomb)||(s->id==wSBomb)) && s->hit(this) && !superman && (scriptcoldet&1) && !fallclk)
6607 {
6608 std::vector<int32_t> &ev = FFCore.eventData;
6609 ev.clear();
6610 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6611 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6612 ev.push_back(0);
6613 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6614 ev.push_back(48*10000);
6615 ev.push_back(ZSD_LWPN*10000);
6616 ev.push_back(s->getUID());
6617
6618 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6619 int32_t dmg = ev[0]/10000;
6620 bool nullhit = ev[2] != 0;
6621
6622 if(nullhit) {ev.clear(); return;}
6623
6624 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6625 ev[0] = ringpower(dmg)*10000;
6626
6627 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6628 dmg = ev[0]/10000;
6629 int32_t hdir = ev[1]/10000;
6630 nullhit = ev[2] != 0;
6631 bool nayrulove = ev[3] != 0;
6632 int32_t iframes = ev[4] / 10000;
6633 ev.clear();
6634 if(nullhit) return;
6635 if(!nayrulove)
6636 {
6637 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6638 }
6639
6640 hitdir = hdir;
6641
6642 if (action != rafting && action != freeze && action != sideswimfreeze)
6643 {
6644 if (IsSideSwim())
6645 {
6646 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6647 }
6648 else if (action == swimming || hopclk == 0xFF)
6649 {
6650 action=swimhit; FFCore.setHeroAction(swimhit);
6651 }
6652 else
6653 {
6654 action=gothit; FFCore.setHeroAction(gothit);
6655 }
6656 }
6657
6658 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6659 {
6660 spins = charging = attackclk = 0;
6661 attack=none;
6662 tapping = false;
6663 }
6664
6665 hclk=iframes;
6666 sfx(getHurtSFX(),pan(x.getInt()));
6667 return;
6668 }
6669 422396 }
6670
6671
7/8
✓ Branch 0 taken 1110776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3201 times.
✓ Branch 3 taken 1107575 times.
✓ Branch 4 taken 3180 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 1110755 times.
✓ Branch 7 taken 21 times.
1110776 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6672 {
6673 21 std::vector<int32_t> &ev = FFCore.eventData;
6674 21 ev.clear();
6675 21 ev.push_back(0);
6676 21 ev.push_back(s->dir*10000);
6677 21 ev.push_back(0);
6678 21 ev.push_back(0);
6679 21 ev.push_back(ZSD_LWPN*10000);
6680 21 ev.push_back(s->getUID());
6681
6682 21 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6683 21 bool nullhit = ev[2] != 0;
6684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(nullhit) {ev.clear(); return;}
6685
6686 21 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6687 21 int32_t hdir = ev[1]/10000;
6688 21 nullhit = ev[2] != 0;
6689 21 ev.clear();
6690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(nullhit) return;
6691
6692 21 reset_hookshot();
6693 21 xofs=1000;
6694 21 action=inwind; FFCore.setHeroAction(inwind);
6695 21 dir=s->dir=hdir;
6696 21 spins = charging = attackclk = 0;
6697
6698 // In case Hero used two whistles in a row, summoning two whirlwinds,
6699 // check which whistle's whirlwind picked him up so the correct
6700 // warp ring will be used
6701 21 int32_t whistle=((weapon*)s)->parentitem;
6702
6703
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6704 21 whistleitem=whistle;
6705
6706 21 return;
6707 }
6708 1110755 }
6709
6710
6/8
✓ Branch 0 taken 2274737 times.
✓ Branch 1 taken 12518 times.
✓ Branch 2 taken 2232351 times.
✓ Branch 3 taken 42386 times.
✓ Branch 4 taken 2232351 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2232351 times.
4519606 if(action==rafting || action==freeze || action==sideswimfreeze ||
6711
4/8
✓ Branch 0 taken 2232351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2232351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2232351 times.
✗ Branch 7 not taken.
2232351 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6712 54904 return;
6713
6714 2232351 int32_t hit2 = -1;
6715 2232351 do
6716 {
6717
2/2
✓ Branch 0 taken 9059 times.
✓ Branch 1 taken 2225468 times.
2234527 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6718 2225468 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6719
6720
2/2
✓ Branch 0 taken 2228948 times.
✓ Branch 1 taken 5579 times.
2234527 if(hit2!=-1)
6721 {
6722
2/2
✓ Branch 0 taken 2176 times.
✓ Branch 1 taken 3403 times.
5579 if (hithero(hit2) == 0) return;
6723 2176 }
6724
2/2
✓ Branch 0 taken 2176 times.
✓ Branch 1 taken 2228948 times.
2231124 } while (hit2 != -1);
6725
5/6
✓ Branch 0 taken 2169445 times.
✓ Branch 1 taken 59503 times.
✓ Branch 2 taken 2161244 times.
✓ Branch 3 taken 8201 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2161244 times.
2228948 if (superman || !(scriptcoldet&1) || fallclk) return;
6726 2161244 hit2 = LwpnHit();
6727
6728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2161244 times.
2161244 if(hit2!=-1)
6729 {
6730 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6731 std::vector<int32_t> &ev = FFCore.eventData;
6732 ev.clear();
6733 ev.push_back((lwpn_dp(hit2)*10000));
6734 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6735 ev.push_back(0);
6736 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6737 ev.push_back(48*10000);
6738 ev.push_back(ZSD_LWPN*10000);
6739 ev.push_back(lwpnspr->getUID());
6740
6741 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6742 int32_t dmg = ev[0]/10000;
6743 bool nullhit = ev[2] != 0;
6744
6745 if(nullhit) {ev.clear(); return;}
6746
6747 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6748 ev[0] = ringpower(dmg)*10000;
6749
6750 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6751 dmg = ev[0]/10000;
6752 int32_t hdir = ev[1]/10000;
6753 nullhit = ev[2] != 0;
6754 bool nayrulove = ev[3] != 0;
6755 int32_t iframes = ev[4] / 10000;
6756 ev.clear();
6757 if(nullhit) return;
6758 if(!nayrulove)
6759 {
6760 game->set_life(zc_max(game->get_life()-dmg,0));
6761 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6762 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6763 }
6764
6765 hitdir = hdir;
6766 lwpnspr->onhit(false);
6767
6768 if (IsSideSwim())
6769 {
6770 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6771 }
6772 else if(action==swimming || hopclk==0xFF)
6773 {
6774 action=swimhit; FFCore.setHeroAction(swimhit);
6775 }
6776 else
6777 {
6778 action=gothit; FFCore.setHeroAction(gothit);
6779 }
6780
6781 hclk=iframes;
6782
6783 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6784 {
6785 spins = charging = attackclk = 0;
6786 attack=none;
6787 tapping = false;
6788 }
6789
6790 sfx(getHurtSFX(),pan(x.getInt()));
6791 return;
6792 }
6793
6794 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6795
6796 2161244 hit2 = EwpnHit();
6797
6798
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 2159788 times.
2161244 if(hit2!=-1)
6799 {
6800 1456 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6801 1456 std::vector<int32_t> &ev = FFCore.eventData;
6802 1456 ev.clear();
6803 1456 ev.push_back((ewpn_dp(hit2)*10000));
6804 1456 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6805 1456 ev.push_back(0);
6806 1456 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6807 1456 ev.push_back(48*10000);
6808 1456 ev.push_back(ZSD_EWPN*10000);
6809 1456 ev.push_back(ewpnspr->getUID());
6810
6811 1456 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6812 1456 int32_t dmg = ev[0]/10000;
6813 1456 bool nullhit = ev[2] != 0;
6814
6815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1456 times.
1456 if(nullhit) {ev.clear(); return;}
6816
6817 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6818 1456 ev[0] = ringpower(dmg)*10000;
6819
6820 1456 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6821 1456 dmg = ev[0]/10000;
6822 1456 int32_t hdir = ev[1]/10000;
6823 1456 nullhit = ev[2] != 0;
6824 1456 bool nayrulove = ev[3] != 0;
6825 1456 int32_t iframes = ev[4] / 10000;
6826 1456 ev.clear();
6827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1456 times.
1456 if(nullhit) return;
6828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1456 times.
1456 if(!nayrulove)
6829 {
6830
2/2
✓ Branch 0 taken 1455 times.
✓ Branch 1 taken 1 times.
1456 game->set_life(zc_max(game->get_life()-dmg,0));
6831 1456 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6832 1456 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6833 1456 }
6834
6835 1456 hitdir = hdir;
6836 1456 ewpnspr->onhit(false);
6837
6838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1456 times.
1456 if (IsSideSwim())
6839 {
6840 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6841 }
6842
3/4
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1454 times.
1456 else if(action==swimming || hopclk==0xFF)
6843 {
6844 2 action=swimhit; FFCore.setHeroAction(swimhit);
6845 2 }
6846 else
6847 {
6848 1454 action=gothit; FFCore.setHeroAction(gothit);
6849 }
6850
6851 1456 hclk=iframes;
6852
6853
5/8
✓ Branch 0 taken 1456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 373 times.
✓ Branch 5 taken 1083 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 373 times.
1456 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6854 {
6855 1083 spins = charging = attackclk = 0;
6856 1083 attack=none;
6857 1083 tapping = false;
6858 1083 }
6859
6860 1456 sfx(getHurtSFX(),pan(x.getInt()));
6861 1456 return;
6862 }
6863 //else { sethitHeroUID(HIT_BY_EWEAPON,(0)); } //fails to clear
6864
6865 // The rest of this method deals with damage combos, which can be jumped over.
6866
2/4
✓ Branch 0 taken 2159788 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2159788 times.
✗ Branch 3 not taken.
2159788 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6867
6868 2159788 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6869 2159788 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2159788 times.
2159788 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2159788 times.
2159788 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6872
6873
2/2
✓ Branch 0 taken 2159788 times.
✓ Branch 1 taken 3557190 times.
5716978 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6874 3557190 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6875 2441884 }
6876
6877 21 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6878 {
6879 21 return checkdamagecombos(dx,dx,dy,dy);
6880 }
6881
6882 21 void HeroClass::doHit(int32_t hdir)
6883 {
6884 21 hitdir = hdir;
6885
6886
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
21 if (action != rafting && action != freeze && action != sideswimfreeze)
6887 {
6888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (IsSideSwim())
6889 {
6890 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6891 }
6892
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 else if (action == swimming || hopclk == 0xFF)
6893 {
6894 action=swimhit; FFCore.setHeroAction(swimhit);
6895 }
6896 else
6897 {
6898 21 action=gothit; FFCore.setHeroAction(gothit);
6899 }
6900 21 }
6901
6902 21 hclk=48;
6903
6904
5/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10 times.
21 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6905 {
6906 11 spins = charging = attackclk = 0;
6907 11 attack=none;
6908 11 tapping = false;
6909 11 }
6910
6911 21 sfx(getHurtSFX(),pan(x.getInt()));
6912 21 }
6913
6914 3607558 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6915 {
6916
3/6
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607558 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3607558 times.
3607558 if(hclk || superman || fallclk)
6917 return false;
6918
6919 3607558 int32_t hp_mod[4] = {0};
6920 int32_t cid[8];
6921 3607558 byte hasKB = 0;
6922
6923 {
6924
2/2
✓ Branch 0 taken 1430967 times.
✓ Branch 1 taken 2176591 times.
3607558 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6925 3607558 newcombo& cmb = combobuf[cid[0]];
6926
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607550 times.
✓ Branch 3 taken 8 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6927 {
6928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(cmb.usrflags&cflag1)
6929 hp_mod[0] = cmb.attributes[0] / -10000L;
6930 else
6931 8 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!(cmb.usrflags&cflag2))
6933 8 hasKB |= 1<<0;
6934 8 }
6935 }
6936 {
6937
2/2
✓ Branch 0 taken 1430967 times.
✓ Branch 1 taken 2176591 times.
3607558 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6938 3607558 newcombo& cmb = combobuf[cid[1]];
6939
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607549 times.
✓ Branch 3 taken 9 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6940 {
6941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(cmb.usrflags&cflag1)
6942 hp_mod[1] = cmb.attributes[0] / -10000L;
6943 else
6944 9 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(cmb.usrflags&cflag2))
6946 9 hasKB |= 1<<1;
6947 9 }
6948 }
6949 {
6950
2/2
✓ Branch 0 taken 1430967 times.
✓ Branch 1 taken 2176591 times.
3607558 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6951 3607558 newcombo& cmb = combobuf[cid[2]];
6952
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607545 times.
✓ Branch 3 taken 13 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6953 {
6954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(cmb.usrflags&cflag1)
6955 hp_mod[2] = cmb.attributes[0] / -10000L;
6956 else
6957 13 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!(cmb.usrflags&cflag2))
6959 13 hasKB |= 1<<2;
6960 13 }
6961 }
6962 {
6963
2/2
✓ Branch 0 taken 1430967 times.
✓ Branch 1 taken 2176591 times.
3607558 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6964 3607558 newcombo& cmb = combobuf[cid[3]];
6965
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607545 times.
✓ Branch 3 taken 13 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6966 {
6967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(cmb.usrflags&cflag1)
6968 hp_mod[3] = cmb.attributes[0] / -10000L;
6969 else
6970 13 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!(cmb.usrflags&cflag2))
6972 13 hasKB |= 1<<3;
6973 13 }
6974 }
6975
6976 3607558 int32_t bestcid=0;
6977 3607558 int32_t hp_modtotal=0;
6978
2/2
✓ Branch 0 taken 2634727 times.
✓ Branch 1 taken 972831 times.
3607558 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6979
2/2
✓ Branch 0 taken 2633178 times.
✓ Branch 1 taken 974380 times.
3607558 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6980
2/2
✓ Branch 0 taken 2634751 times.
✓ Branch 1 taken 972807 times.
3607558 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6981
2/2
✓ Branch 0 taken 2633202 times.
✓ Branch 1 taken 974356 times.
3607558 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6982
6983
2/2
✓ Branch 0 taken 7215116 times.
✓ Branch 1 taken 3607558 times.
10822674 for (int32_t i = 0; i <= 1; ++i)
6984 {
6985
2/2
✓ Branch 0 taken 5816671 times.
✓ Branch 1 taken 1398445 times.
7215116 if(tmpscr2[i].valid!=0)
6986 {
6987
2/2
✓ Branch 0 taken 1390822 times.
✓ Branch 1 taken 7623 times.
1398445 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6988 {
6989
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6993 1390822 }
6994 else
6995 {
6996
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7000 }
7001 1398445 }
7002 7215116 }
7003
7004
2/2
✓ Branch 0 taken 14430232 times.
✓ Branch 1 taken 3607558 times.
18037790 for(int32_t i=0; i<4; i++)
7005 {
7006
2/2
✓ Branch 0 taken 8376984 times.
✓ Branch 1 taken 6053248 times.
14430232 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7007 {
7008
2/2
✓ Branch 0 taken 8376949 times.
✓ Branch 1 taken 35 times.
8376984 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7009 {
7010
2/2
✓ Branch 0 taken 8376932 times.
✓ Branch 1 taken 17 times.
8376949 if(hp_mod[i] < hp_modtotal)
7011 {
7012 17 hp_modtotal = hp_mod[i];
7013 17 bestcid = cid[i];
7014 17 }
7015 8376949 }
7016
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7017 {
7018
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(hp_mod[i] > hp_modtotal)
7019 {
7020 hp_modtotal = hp_mod[i];
7021 bestcid = cid[i];
7022 }
7023 26 }
7024 8376984 }
7025
1/2
✓ Branch 0 taken 6053248 times.
✗ Branch 1 not taken.
6053248 else if(hp_mod[i] < hp_modtotal)
7026 {
7027 hp_modtotal = hp_mod[i];
7028 bestcid = cid[i];
7029 }
7030 14430232 }
7031
7032 {
7033 3607558 cid[4] = MAPFFCOMBO(dx1,dy1);
7034 3607558 newcombo& cmb = combobuf[cid[4]];
7035
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607159 times.
✓ Branch 3 taken 399 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7036 {
7037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
7038 hp_mod[0] = cmb.attributes[0]/10000L;
7039 else
7040 399 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7041
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
7042 hasKB |= 1<<4;
7043 399 }
7044 }
7045 {
7046 3607558 cid[5] = MAPFFCOMBO(dx1,dy2);
7047 3607558 newcombo& cmb = combobuf[cid[5]];
7048
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607159 times.
✓ Branch 3 taken 399 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7049 {
7050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
7051 hp_mod[1] = cmb.attributes[0]/10000L;
7052 else
7053 399 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7054
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
7055 hasKB |= 1<<5;
7056 399 }
7057 }
7058 {
7059 3607558 cid[6] = MAPFFCOMBO(dx2,dy1);
7060 3607558 newcombo& cmb = combobuf[cid[6]];
7061
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607159 times.
✓ Branch 3 taken 399 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7062 {
7063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
7064 hp_mod[2] = cmb.attributes[0]/10000L;
7065 else
7066 399 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7067
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
7068 hasKB |= 1<<6;
7069 399 }
7070 }
7071 {
7072 3607558 cid[7] = MAPFFCOMBO(dx2,dy2);
7073 3607558 newcombo& cmb = combobuf[cid[7]];
7074
3/4
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3607159 times.
✓ Branch 3 taken 399 times.
3607558 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7075 {
7076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(cmb.usrflags&cflag1 )
7077 hp_mod[3] = cmb.attributes[0]/10000L;
7078 else
7079 399 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7080
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(!(cmb.usrflags&cflag2))
7081 hasKB |= 1<<7;
7082 399 }
7083 }
7084
7085 3607558 int32_t bestffccid = 0;
7086 3607558 int32_t hp_modtotalffc = 0;
7087
7088
2/2
✓ Branch 0 taken 7215116 times.
✓ Branch 1 taken 3607558 times.
10822674 for (int32_t i = 0; i <= 1; ++i)
7089 {
7090
2/2
✓ Branch 0 taken 5816671 times.
✓ Branch 1 taken 1398445 times.
7215116 if(tmpscr2[i].valid!=0)
7091 {
7092
2/2
✓ Branch 0 taken 1390822 times.
✓ Branch 1 taken 7623 times.
1398445 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7093 {
7094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1390822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1390822 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7098 1390822 }
7099 else
7100 {
7101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7623 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7105 }
7106 1398445 }
7107 7215116 }
7108
7109
2/2
✓ Branch 0 taken 14430232 times.
✓ Branch 1 taken 3607558 times.
18037790 for(int32_t i=0; i<4; i++)
7110 {
7111
2/2
✓ Branch 0 taken 8376984 times.
✓ Branch 1 taken 6053248 times.
14430232 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7112 {
7113
2/2
✓ Branch 0 taken 8376949 times.
✓ Branch 1 taken 35 times.
8376984 if(hp_modtotalffc >= 0)
7114 {
7115
2/2
✓ Branch 0 taken 8376932 times.
✓ Branch 1 taken 17 times.
8376949 if(hp_mod[i] < hp_modtotalffc)
7116 {
7117 17 hp_modtotalffc = hp_mod[i];
7118 17 bestffccid = cid[4+i];
7119 17 }
7120 8376949 }
7121
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 else if(hp_mod[i] < 0)
7122 {
7123
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(hp_mod[i] > hp_modtotalffc)
7124 {
7125 hp_modtotalffc = hp_mod[i];
7126 bestffccid = cid[4+i];
7127 }
7128 26 }
7129 8376984 }
7130
2/2
✓ Branch 0 taken 6052849 times.
✓ Branch 1 taken 399 times.
6053248 else if(hp_mod[i] < hp_modtotalffc)
7131 {
7132 399 hp_modtotalffc = hp_mod[i];
7133 399 bestffccid = cid[4+i];
7134 399 }
7135 14430232 }
7136
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3607558 times.
3607558 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7138
1/2
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
3607558 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7139
7140 3607558 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7141 3607558 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7142 3607558 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7143
1/2
✓ Branch 0 taken 3607558 times.
✗ Branch 1 not taken.
3607558 if(current_ring)
7144 {
7145 global_defring = !global_defring;
7146 global_perilring = !global_perilring;
7147 }
7148 3607558 int32_t itemid = current_item_id(itype_boots);
7149
7150
2/2
✓ Branch 0 taken 3558125 times.
✓ Branch 1 taken 49433 times.
3607558 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7151
2/2
✓ Branch 0 taken 3558125 times.
✓ Branch 1 taken 49433 times.
3607558 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7152
7153
2/2
✓ Branch 0 taken 3607142 times.
✓ Branch 1 taken 416 times.
3607558 if(hp_modmin<0)
7154 {
7155
8/14
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 390 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 390 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 390 times.
✓ Branch 10 taken 390 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 390 times.
416 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7156 {
7157
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8 times.
26 if (!do_health_check) return true;
7158 18 std::vector<int32_t> &ev = FFCore.eventData;
7159 18 ev.clear();
7160 18 ev.push_back(-hp_modmin*10000);
7161
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 ev.push_back((hasKB ? dir^1 : -1)*10000);
7162 18 ev.push_back(0);
7163 18 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7164 18 ev.push_back(48*10000);
7165 18 ev.push_back(ZSD_COMBODATA*10000);
7166 18 ev.push_back(bestcid);
7167
7168 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7169 18 int32_t dmg = ev[0]/10000;
7170 18 bool nullhit = ev[2] != 0;
7171
7172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) {ev.clear(); return false;}
7173
7174 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7175 18 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7176
7177 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7178 18 dmg = ev[0]/10000;
7179 18 int32_t hdir = ev[1]/10000;
7180 18 nullhit = ev[2] != 0;
7181 18 bool nayrulove = ev[3] != 0;
7182 18 int32_t iframes = ev[4] / 10000;
7183 18 ev.clear();
7184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) return false;
7185
7186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!nayrulove)
7187 {
7188
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 game->set_life(zc_max(game->get_life()-dmg,0));
7189 18 }
7190
7191 18 hitdir = hdir;
7192 18 doHit(hitdir);
7193 18 hclk = iframes;
7194 18 return true;
7195 }
7196
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7197 390 }
7198
7199 3607532 return false;
7200 3607558 }
7201
7202 5618 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7203 {
7204
1/2
✓ Branch 0 taken 5618 times.
✗ Branch 1 not taken.
5618 if(force_hdir > 3) force_hdir = -1;
7205 5618 enemy* enemyptr = (enemy*)guys.spr(hit2);
7206
1/2
✓ Branch 0 taken 5618 times.
✗ Branch 1 not taken.
5618 if(!enemyptr) return 0;
7207 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7208 5618 int32_t stompid = current_item_id(itype_stompboots);
7209
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
5618 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7210 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7211 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7212 {
7213 paymagiccost(stompid);
7214 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7215
7216 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7217 {
7218 fall = -(itemsbuf[stompid].misc1);
7219 }
7220
7221 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7222 game->set_item(stompid,false);
7223
7224 // Stomp Boots script
7225 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7226 {
7227 //clear the item script stack for a new script
7228 ri = &(itemScriptData[stompid]);
7229 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7230 ri->Clear();
7231 //itemScriptData[(stompid & 0xFFF)].Clear();
7232 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7233 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7234 item_doscript[stompid] = 1;
7235 itemscriptInitialised[stompid] = 0;
7236 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7237 }
7238
7239 return -1;
7240 }
7241
5/6
✓ Branch 0 taken 4137 times.
✓ Branch 1 taken 1481 times.
✓ Branch 2 taken 3898 times.
✓ Branch 3 taken 239 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3898 times.
5618 else if(superman || !(scriptcoldet&1) || fallclk)
7242 1720 return 0;
7243 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7244 //!Add a flag check to this if:
7245
5/6
✓ Branch 0 taken 1849 times.
✓ Branch 1 taken 2049 times.
✓ Branch 2 taken 1849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 665 times.
3898 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7246
3/4
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1707 times.
1849 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7247 {
7248 2191 return -1;
7249 }
7250
7251 1707 std::vector<int32_t> &ev = FFCore.eventData;
7252 1707 ev.clear();
7253 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7254 1707 ev.push_back((enemy_dp(hit2) *10000));
7255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1707 times.
1707 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7256 1707 ev.push_back(0);
7257 1707 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7258 1707 ev.push_back(48*10000);
7259 1707 ev.push_back(ZSD_NPC*10000);
7260 1707 ev.push_back(enemyptr->getUID());
7261
7262 1707 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7263 1707 int32_t dmg = ev[0] / 10000;
7264 1707 bool nullhit = ev[2] != 0;
7265
7266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1707 times.
1707 if(nullhit) {ev.clear(); return -1;}
7267
7268 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7269 1707 ev[0] = ((ringpower(dmg)*10000));
7270
7271 1707 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7272 1707 dmg = ev[0] / 10000;
7273 1707 int32_t hdir = ev[1] / 10000;
7274 1707 nullhit = ev[2] != 0;
7275 1707 bool nayrulove = ev[3] != 0;
7276 1707 int32_t iframes = ev[4] / 10000;
7277 1707 ev.clear();
7278
7279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1707 times.
1707 if(nullhit) return -1;
7280
7281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1707 times.
1707 if(!nayrulove)
7282 {
7283
2/2
✓ Branch 0 taken 1701 times.
✓ Branch 1 taken 6 times.
1707 game->set_life(zc_max(game->get_life()-dmg,0));
7284 1707 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7285 1707 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7286 1707 }
7287
7288 1707 hitdir = hdir;
7289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1707 times.
1707 if (IsSideSwim())
7290 {
7291 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7292 }
7293
3/4
✓ Branch 0 taken 1705 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1705 times.
1707 else if(action==swimming || hopclk==0xFF)
7294 {
7295 2 action=swimhit; FFCore.setHeroAction(swimhit);
7296 2 }
7297 else
7298 {
7299 1705 action=gothit; FFCore.setHeroAction(gothit);
7300 }
7301
7302 1707 hclk=iframes;
7303 1707 sfx(getHurtSFX(),pan(x.getInt()));
7304
7305
5/8
✓ Branch 0 taken 1707 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✓ Branch 5 taken 1227 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 480 times.
1707 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7306 {
7307 1227 spins = charging = attackclk = 0;
7308 1227 attack=none;
7309 1227 tapping = false;
7310 1227 }
7311
7312 1707 enemy_scored(hit2);
7313 1707 int32_t dm7 = enemyptr->dmisc7;
7314 1707 int32_t dm8 = enemyptr->dmisc8;
7315
7316
3/3
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1033 times.
1707 switch(enemyptr->family)
7317 {
7318 case eeWALLM:
7319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(enemyptr->hp>0)
7320 {
7321 2 GrabHero(hit2);
7322 2 inwallm=true;
7323 2 action=none; FFCore.setHeroAction(none);
7324 2 }
7325 2 break;
7326
7327 //case eBUBBLEST:
7328 //case eeBUBBLE:
7329 case eeWALK:
7330 {
7331 1033 int32_t itemid = current_item_id(itype_whispring);
7332 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7333
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
1033 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7334
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
1033 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7335
7336
5/7
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
1033 switch(dm7)
7337 {
7338 case e7tTEMPJINX:
7339
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
148 if(dm8==0 || dm8==2)
7340
3/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
259 if(swordclk>=0 && !(sworddivisor==0))
7341 129 swordclk=150;
7342
7343
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
148 if(dm8==1 || dm8==2)
7344
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
36 if(itemclk>=0 && !(itemdivisor==0))
7345 18 itemclk=150;
7346
7347 148 break;
7348
7349 case e7tPERMJINX:
7350
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
46 if(dm8==0 || dm8==2)
7351
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
30 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7352
7353
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
46 if(dm8==1 || dm8==2)
7354
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
16 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7355
7356 46 break;
7357
7358 case e7tUNJINX:
7359
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
58 if(dm8==0 || dm8==2)
7360 46 swordclk=0;
7361
7362
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
58 if(dm8==1 || dm8==2)
7363 12 itemclk=0;
7364
7365 58 break;
7366
7367 case e7tTAKEMAGIC:
7368 game->change_dmagic(-dm8*game->get_magicdrainrate());
7369 break;
7370
7371 case e7tTAKERUPEES:
7372 21 game->change_drupy(-dm8);
7373 21 break;
7374
7375 case e7tDRUNK:
7376 drunkclk += dm8;
7377 break;
7378 }
7379 1033 verifyAWpn();
7380
2/2
✓ Branch 0 taken 998 times.
✓ Branch 1 taken 35 times.
1033 if(dm7 >= e7tEATITEMS)
7381 {
7382 35 EatHero(hit2);
7383 35 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7384 35 action=none; FFCore.setHeroAction(none);
7385 35 }
7386 }
7387 1033 }
7388 1707 return 0;
7389 5618 }
7390
7391 142473 void HeroClass::addsparkle(int32_t wpn)
7392 {
7393 //return;
7394 142473 weapon *w = (weapon*)Lwpns.spr(wpn);
7395 142473 int32_t itemid = w->parentitem;
7396
7397
1/2
✓ Branch 0 taken 142473 times.
✗ Branch 1 not taken.
142473 if(itemid<0)
7398 return;
7399
7400 142473 int32_t itemtype = itemsbuf[itemid].family;
7401
7402
3/4
✓ Branch 0 taken 142473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35626 times.
✓ Branch 3 taken 106847 times.
142473 if(itemtype!=itype_cbyrna && frame%4)
7403 106847 return;
7404
7405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35626 times.
35626 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35626 times.
35626 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7407 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7408
4/8
✓ Branch 0 taken 14380 times.
✓ Branch 1 taken 21246 times.
✓ Branch 2 taken 21246 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14380 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35626 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7409 35626 int32_t direction=w->dir;
7410
7411
2/2
✓ Branch 0 taken 21246 times.
✓ Branch 1 taken 14380 times.
35626 if(sparkle_type)
7412 {
7413 14380 int32_t h=0;
7414 14380 int32_t v=0;
7415
7416
6/6
✓ Branch 0 taken 11063 times.
✓ Branch 1 taken 3317 times.
✓ Branch 2 taken 10161 times.
✓ Branch 3 taken 902 times.
✓ Branch 4 taken 2080 times.
✓ Branch 5 taken 8081 times.
14380 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7417 {
7418 6299 h=-1;
7419 6299 }
7420
7421
6/6
✓ Branch 0 taken 11209 times.
✓ Branch 1 taken 3171 times.
✓ Branch 2 taken 9369 times.
✓ Branch 3 taken 1840 times.
✓ Branch 4 taken 1083 times.
✓ Branch 5 taken 8286 times.
14380 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7422 {
7423 6094 h=1;
7424 6094 }
7425
7426
6/6
✓ Branch 0 taken 13556 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 12473 times.
✓ Branch 3 taken 1083 times.
✓ Branch 4 taken 2080 times.
✓ Branch 5 taken 10393 times.
14380 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7427 {
7428 3987 v=-1;
7429 3987 }
7430
7431
6/6
✓ Branch 0 taken 13217 times.
✓ Branch 1 taken 1163 times.
✓ Branch 2 taken 11377 times.
✓ Branch 3 taken 1840 times.
✓ Branch 4 taken 902 times.
✓ Branch 5 taken 10475 times.
14380 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7432 {
7433 3905 v=1;
7434 3905 }
7435
7436 // Damaging boomerang sparkle?
7437
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14380 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14380 if(wpn3 && itemtype==itype_brang)
7438 {
7439 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7440 // whatever it just bounced off of if it's shielded from that direction.
7441 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7442 direction=oppositeDir[direction];
7443 }
7444
2/4
✓ Branch 0 taken 14380 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14380 times.
14380 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14380 times.
14380 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14380 times.
14380 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7447
5/10
✓ Branch 0 taken 14380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14380 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14380 times.
✗ Branch 9 not taken.
14380 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7448 14380 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7449 14380 }
7450 142473 }
7451
7452 // For wPhantoms
7453 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7454 {
7455 if(frame%4) return;
7456
7457 int32_t arrow = -1;
7458
7459 for(int32_t i=0; i<Lwpns.Count(); i++)
7460 {
7461 weapon *w = (weapon*)Lwpns.spr(i);
7462
7463 if(w->id == wPhantom && w->type == type1)
7464 {
7465 arrow = i;
7466 break;
7467 }
7468 }
7469
7470 if(arrow==-1)
7471 {
7472 return;
7473 }
7474
7475 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7476 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7477 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7478 }
7479
7480 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7481 2441644 void HeroClass::PhantomsCleanup()
7482 {
7483
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 if(Lwpns.idCount(wPhantom))
7484 {
7485 for(int32_t i=0; i<Lwpns.Count(); i++)
7486 {
7487 weapon *w = ((weapon *)Lwpns.spr(i));
7488 if ( w->id == wPhantom && !w->isScriptGenerated() )
7489 {
7490 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7491 {
7492 Lwpns.remove(w);
7493 }
7494 }
7495 }
7496 }
7497 2441644 }
7498
7499 //Waitframe handler for refilling operations
7500 4008 static void do_refill_waitframe()
7501 {
7502 4008 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7503
1/2
✓ Branch 0 taken 4008 times.
✗ Branch 1 not taken.
4008 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7504 {
7505 script_drawing_commands.Clear();
7506 if(DMaps[currdmap].passive_sub_script != 0)
7507 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7508 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7509 {
7510 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7511 passive_subscreen_waitdraw = false;
7512 }
7513 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7514 }
7515 4008 advanceframe(true);
7516 4008 }
7517 //Special handler if it's a "fairy revive"
7518 static void do_death_refill_waitframe()
7519 {
7520 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7521 //This script should be able to draw a 'fairy saving the player' animation -Em
7522 do_refill_waitframe();
7523 }
7524
7525 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7526 {
7527 int32_t found_unowned = -1;
7528 for(int q = 0; q < MAXITEMS; ++q)
7529 {
7530 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7531 {
7532 if(game->get_item(q))
7533 return q;
7534 if(unowned)
7535 found_unowned = q;
7536 }
7537 }
7538 return found_unowned;
7539 }
7540
7541 int32_t getPushDir(int32_t flag)
7542 {
7543 switch(flag)
7544 {
7545 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7546 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7547 case mfPUSHUINS:
7548 return up;
7549 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7550 return down;
7551 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7552 case mfPUSHLRINS: case mfPUSHLINS:
7553 return left;
7554 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7555 return right;
7556 }
7557 return -1;
7558 }
7559
7560 // returns true when game over
7561 7312766 bool HeroClass::animate(int32_t)
7562 {
7563 7312766 int32_t lsave=0;
7564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7312766 times.
7312766 if(immortal > 0)
7565 --immortal;
7566 7312766 prompt_combo = 0;
7567
2/2
✓ Branch 0 taken 4870882 times.
✓ Branch 1 taken 2441884 times.
7312766 if (onpassivedmg)
7568 {
7569 4870882 onpassivedmg=false;
7570 4870882 }
7571
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 else if (damageovertimeclk)
7572 {
7573 damageovertimeclk = 0;
7574 }
7575
7576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7312766 times.
7312766 if(cheats_execute_goto)
7577 {
7578 didpit=true;
7579 pitx=x;
7580 pity=y;
7581 dowarp(3,0);
7582 cheats_execute_goto=false;
7583 solid_update(false);
7584 return false;
7585 }
7586
7587
1/2
✓ Branch 0 taken 7312766 times.
✗ Branch 1 not taken.
7312766 if(cheats_execute_light)
7588 {
7589 naturaldark = !naturaldark;
7590 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7591 cheats_execute_light = false;
7592 }
7593
7594
3/4
✓ Branch 0 taken 2441884 times.
✓ Branch 1 taken 4870882 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2441884 times.
7312766 if(action!=climbcovertop&&action!=climbcoverbottom)
7595 {
7596 2441884 climb_cover_x=-1000;
7597 2441884 climb_cover_y=-1000;
7598 2441884 }
7599
7600
1/2
✓ Branch 0 taken 7312766 times.
✗ Branch 1 not taken.
7312766 if(mirror_portal)
7601 {
7602 mirror_portal->animate(0);
7603 if(abs(x - mirror_portal->x) < 12
7604 && abs(y - mirror_portal->y) < 12)
7605 {
7606 if(can_mirror_portal)
7607 {
7608 //Store some values to restore if 'warp fails'
7609 int32_t tLastEntrance = lastentrance,
7610 tLastEntranceDMap = lastentrance_dmap,
7611 tContScr = game->get_continue_scrn(),
7612 tContDMap = game->get_continue_dmap();
7613 int32_t sourcescr = currscr, sourcedmap = currdmap;
7614 zfix tx = x, ty = y, tz = z;
7615 x = mirror_portal->x;
7616 y = mirror_portal->y;
7617
7618 int32_t weff = mirror_portal->weffect,
7619 wsfx = mirror_portal->wsfx;
7620
7621 FFCore.warp_player(wtIWARP, mirror_portal->destdmap, mirror_portal->destscr,
7622 -1, -1, weff, wsfx, 0, -1);
7623
7624 if(mirrorBonk()) //Invalid landing, warp back!
7625 {
7626 action = none; FFCore.setHeroAction(none);
7627 lastentrance = tLastEntrance;
7628 lastentrance_dmap = tLastEntranceDMap;
7629 game->set_continue_scrn(tContScr);
7630 game->set_continue_dmap(tContDMap);
7631 x = tx;
7632 y = ty;
7633 z = tz;
7634 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7635 wsfx, 0, -1);
7636 can_mirror_portal = false;
7637 }
7638 else game->clear_portal(); //Remove portal once used
7639 }
7640 }
7641 else can_mirror_portal = true;
7642 }
7643
7644
3/4
✓ Branch 0 taken 2441776 times.
✓ Branch 1 taken 4870990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2441776 times.
7312766 if(z<=8&&fakez<=8)
7645 {
7646
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 2441157 times.
2441776 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7647 {
7648 619 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7650 {
7651
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7652
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7653
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7654
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7655 619 }
7656
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
619 if(g1 && g2 && g3 && g4)
7657 {
7658 if(decorations.idCount(dTALLGRASS)==0)
7659 {
7660 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7661 }
7662 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7663 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7664 sfx(thesfx,pan((int32_t)x));
7665 }
7666 619 }
7667 else
7668 {
7669 2441157 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7670
2/2
✓ Branch 0 taken 8811 times.
✓ Branch 1 taken 2432346 times.
2441157 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7671 {
7672
2/4
✓ Branch 0 taken 8811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8811 times.
8811 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7673
2/4
✓ Branch 0 taken 8811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8811 times.
8811 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7674 8811 }
7675
4/4
✓ Branch 0 taken 35205 times.
✓ Branch 1 taken 2405952 times.
✓ Branch 2 taken 4476 times.
✓ Branch 3 taken 30729 times.
2441157 if(g1 && g2)
7676 {
7677
2/2
✓ Branch 0 taken 30293 times.
✓ Branch 1 taken 436 times.
30729 if(decorations.idCount(dTALLGRASS)==0)
7678 {
7679
3/6
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 436 times.
✗ Branch 5 not taken.
436 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7680 436 }
7681 30729 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7682
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30729 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30729 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7683 sfx(thesfx,pan((int32_t)x));
7684 30729 }
7685 }
7686 2441776 }
7687
7688
2/2
✓ Branch 0 taken 4880420 times.
✓ Branch 1 taken 2432346 times.
7312766 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7689 {
7690
15/26
✓ Branch 0 taken 9418 times.
✓ Branch 1 taken 4871002 times.
✓ Branch 2 taken 9418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9418 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9418 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9226 times.
✓ Branch 9 taken 192 times.
✓ Branch 10 taken 9226 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 9226 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 9226 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 9226 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 9226 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 9226 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 9226 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 9226 times.
4880420 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7691 {
7692
2/2
✓ Branch 0 taken 9225 times.
✓ Branch 1 taken 1 times.
9237 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7693
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9215 times.
9226 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7694
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7695
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7696 {
7697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(decorations.idCount(dRIPPLES)==0)
7698 {
7699
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7700 1 }
7701 1 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (combobuf[watercheck].usrflags&cflag2)
7703 {
7704 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7705 {
7706 onpassivedmg = true;
7707 if (!damageovertimeclk)
7708 {
7709 int32_t curhp = game->get_life();
7710 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7711 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7712 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7713 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7714 {
7715 hclk = 48;
7716 hitdir = -1;
7717 action = gothit; FFCore.setHeroAction(gothit);
7718 }
7719 }
7720 if (combobuf[watercheck].attribytes[1] > 0)
7721 {
7722 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7723 else --damageovertimeclk;
7724 }
7725 else damageovertimeclk = 0;
7726 }
7727 else damageovertimeclk = 0;
7728 }
7729 1 else damageovertimeclk = 0;
7730 1 int32_t thesfx = combobuf[watercheck].attribytes[0];
7731
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if (combobuf[watercheck].type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7732 {
7733 1 thesfx = combobuf[watercheck].attribytes[5];
7734 1 }
7735
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7736 sfx(thesfx,pan((int32_t)x));
7737 1 }
7738 9226 }
7739 4880420 }
7740 else
7741 {
7742
7/8
✓ Branch 0 taken 2692 times.
✓ Branch 1 taken 2429654 times.
✓ Branch 2 taken 2615 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2615 times.
✓ Branch 6 taken 2429731 times.
✓ Branch 7 taken 2615 times.
2432346 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7743 {
7744
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 19 times.
2615 if(decorations.idCount(dRIPPLES)==0)
7745 {
7746
3/6
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
19 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7747 19 }
7748 2615 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2615 times.
2615 if (combobuf[watercheck].usrflags&cflag2)
7750 {
7751 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7752 {
7753 onpassivedmg = true;
7754 if (!damageovertimeclk)
7755 {
7756 int32_t curhp = game->get_life();
7757 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7758 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7759 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7760 }
7761 if (combobuf[watercheck].attribytes[1] > 0)
7762 {
7763 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7764 else --damageovertimeclk;
7765 }
7766 else damageovertimeclk = 0;
7767 }
7768 else damageovertimeclk = 0;
7769 }
7770 2615 else damageovertimeclk = 0;
7771 2615 int32_t thesfx = combobuf[watercheck].attribytes[0];
7772
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2615 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7773 sfx(thesfx,pan((int32_t)x));
7774 2615 }
7775 }
7776
7777
2/2
✓ Branch 0 taken 7312763 times.
✓ Branch 1 taken 3 times.
7312766 if(stomping)
7778 3 stomping = false;
7779
7780
2/2
✓ Branch 0 taken 7312462 times.
✓ Branch 1 taken 304 times.
7312766 if(getOnSideviewLadder())
7781 {
7782
4/8
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 304 times.
304 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7783 {
7784 setOnSideviewLadder(false);
7785 }
7786
2/8
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 304 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
304 else if(CANFORCEFACEUP)
7787 {
7788 setDir(up);
7789 }
7790 304 }
7791
7792
6/8
✓ Branch 0 taken 2438934 times.
✓ Branch 1 taken 4873832 times.
✓ Branch 2 taken 2438742 times.
✓ Branch 3 taken 192 times.
✓ Branch 4 taken 2438742 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2438742 times.
7312766 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7793 {
7794
2/2
✓ Branch 0 taken 2429396 times.
✓ Branch 1 taken 9346 times.
2438742 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7795 {
7796 9346 checkchest(cCHEST);
7797 9346 checkchest(cLOCKEDCHEST);
7798 9346 checkchest(cBOSSCHEST);
7799 9346 }
7800
2/2
✓ Branch 0 taken 2429396 times.
✓ Branch 1 taken 9346 times.
2438742 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7801 {
7802 9346 checkchest(cLOCKBLOCK);
7803 9346 checkchest(cBOSSLOCKBLOCK);
7804 9346 }
7805 2438742 }
7806 7312766 checksigns();
7807 7312766 checkgenpush();
7808
7809
4/4
✓ Branch 0 taken 2439837 times.
✓ Branch 1 taken 4872929 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 2439784 times.
7312766 if(isStanding(true) && fall == 0)
7810 {
7811
1/2
✓ Branch 0 taken 2439784 times.
✗ Branch 1 not taken.
2439784 if(extra_jump_count > 0)
7812 extra_jump_count = 0;
7813 2439784 coyotetime = 0;
7814 2439784 }
7815
2/2
✓ Branch 0 taken 4872152 times.
✓ Branch 1 taken 830 times.
4872982 else if(coyotetime < 65535)
7816 {
7817 830 ++coyotetime;
7818 830 }
7819
1/2
✓ Branch 0 taken 7312766 times.
✗ Branch 1 not taken.
7312766 if(can_use_item(itype_hoverboots,i_hoverboots))
7820 {
7821 int32_t hoverid = current_item_id(itype_hoverboots);
7822 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7823 {
7824 if(hoverclk < 0) hoverclk = 0;
7825 hoverflags &= ~HOV_OUT;
7826 }
7827 }
7828 7312766 bool platformfell2 = false;
7829 7312766 int32_t gravity3 = (zinit.gravity2/100);
7830 7312766 int32_t termv = (zinit.terminalv);
7831 7312766 int32_t rocs = getRocsPressed();
7832
2/2
✓ Branch 0 taken 7311839 times.
✓ Branch 1 taken 927 times.
7312766 if (rocs != -1)
7833 {
7834 927 itemdata const& itm = itemsbuf[rocs];
7835
1/2
✓ Branch 0 taken 927 times.
✗ Branch 1 not taken.
927 if (itm.flags & ITEM_FLAG2)
7836 {
7837 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7838 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7839 }
7840
1/2
✓ Branch 0 taken 927 times.
✗ Branch 1 not taken.
927 if (itm.flags & ITEM_FLAG5)
7841 {
7842 termv = itm.misc4;
7843 if (fall > termv) fall = termv;
7844 }
7845 927 }
7846
2/2
✓ Branch 0 taken 6083 times.
✓ Branch 1 taken 7306683 times.
7312766 if(sideview_mode()) // Sideview gravity
7847 {
7848 //Handle falling through a platform
7849 6083 bool platformfell = false;
7850
4/4
✓ Branch 0 taken 3885 times.
✓ Branch 1 taken 2198 times.
✓ Branch 2 taken 3878 times.
✓ Branch 3 taken 7 times.
6083 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7851 {
7852
7/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 3 times.
7 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7853 7 y+=1; //Fall down a pixel instantly, through the platform.
7854
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(fall < 0) fall = 0;
7855
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(jumping < 0) jumping = 0;
7856 7 platformfell2 = true;
7857 7 }
7858 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6083 times.
6083 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7860 {
7861
14/22
✓ Branch 0 taken 5466 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 617 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 617 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 617 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 617 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 616 times.
✓ Branch 12 taken 616 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 616 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 616 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 616 times.
✓ Branch 20 taken 6082 times.
✓ Branch 21 taken 1 times.
6700 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7862
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
✓ Branch 2 taken 601 times.
✓ Branch 3 taken 15 times.
631 || ((y+(fall/100)<=0) &&
7863 // Extra checks if Smart Screen Scrolling is enabled
7864
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7865 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7866 {
7867 1 fall = jumping = 0; // Bumped his head
7868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7869 y -= y.getInt()%8; //fix coords
7870 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7872 {
7873 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7874 1 }
7875 1 }
7876 6083 }
7877 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7878
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 6083 times.
✓ Branch 2 taken 6083 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6083 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6083 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6083 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6083 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 304 times.
✓ Branch 13 taken 5779 times.
6083 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7879 {
7880
1/2
✓ Branch 0 taken 5779 times.
✗ Branch 1 not taken.
5779 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7881 //zprint2("ydif is: %d\n", ydiff);
7882 //zprint2("ydif is: %d\n", (int32_t)fall);
7883 5779 falling_oldy = y; // Stomp Boots-related variable
7884
8/8
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 5025 times.
✓ Branch 2 taken 695 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 752 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 5777 times.
✓ Branch 7 taken 2 times.
5779 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7885 {
7886 2 ydiff -= (y.getInt()+ydiff)%16;
7887 2 }
7888
3/4
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 4603 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1176 times.
5779 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7889 {
7890
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 536 times.
1176 if(ydiff > 0)
7891 {
7892
2/2
✓ Branch 0 taken 622 times.
✓ Branch 1 taken 1366 times.
1988 for(auto q = 0; q < ydiff; ++q)
7893 {
7894
2/2
✓ Branch 0 taken 1348 times.
✓ Branch 1 taken 18 times.
1366 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7895 {
7896 18 ydiff = q;
7897 18 break;
7898 }
7899 1348 }
7900 640 }
7901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 536 times.
536 else if(ydiff < 0)
7902 {
7903
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 1048 times.
1584 for(auto q = 0; q > ydiff; --q)
7904 {
7905
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
2096 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7907 {
7908 ydiff = q;
7909 break;
7910 }
7911 1048 }
7912 536 }
7913 1176 }
7914 5779 y+=ydiff;
7915 5779 hs_starty+=ydiff;
7916
7917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5779 times.
5779 for(int32_t j=0; j<chainlinks.Count(); j++)
7918 {
7919 chainlinks.spr(j)->y+=ydiff;
7920 }
7921
7922
1/2
✓ Branch 0 taken 5779 times.
✗ Branch 1 not taken.
5779 if(Lwpns.idFirst(wHookshot)>-1)
7923 {
7924 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7925 }
7926
7927
1/2
✓ Branch 0 taken 5779 times.
✗ Branch 1 not taken.
5779 if(Lwpns.idFirst(wHSHandle)>-1)
7928 {
7929 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7930 }
7931 5779 }
7932
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
304 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7933 {
7934 fall = hoverclk = jumping = 0;
7935 inair = false;
7936 hoverflags = 0;
7937 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7938 {
7939 WalkflagInfo info;
7940 if (game->get_watergrav()<0)
7941 {
7942 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7943 execute(info);
7944 }
7945 else
7946 {
7947 info = walkflag(x,y+15+2,2,down);
7948 execute(info);
7949 }
7950 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7951 }
7952 }
7953 // Stop hovering/falling if you land on something.
7954 6083 bool needFall = false;
7955
7/8
✓ Branch 0 taken 2207 times.
✓ Branch 1 taken 3876 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6083 times.
✓ Branch 4 taken 4154 times.
✓ Branch 5 taken 1929 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4153 times.
6083 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7956 {
7957 4153 stop_item_sfx(itype_hoverboots);
7958
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4153 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4153 times.
4153 && !getOnSideviewLadder()
7960 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
7961 y-=(int32_t)y%8; //fix position
7962 4153 fall = hoverclk = jumping = 0;
7963 4153 inair = false;
7964 4153 hoverflags = 0;
7965
7966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4153 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4153 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
7967 y = 160;
7968 4153 }
7969 // Stop hovering if you press down.
7970
3/6
✓ Branch 0 taken 1930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1930 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1930 times.
✗ Branch 5 not taken.
1930 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
7971 {
7972 stop_item_sfx(itype_hoverboots);
7973 hoverclk = -hoverclk;
7974 reset_ladder();
7975 fall = gravity3;
7976 inair = false;
7977 }
7978
7/8
✓ Branch 0 taken 1930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 616 times.
✓ Branch 3 taken 1314 times.
✓ Branch 4 taken 584 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 581 times.
1930 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell)
7979 {
7980 581 zfix my = y + gravity3;
7981 581 needFall = true;
7982
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1258 times.
1271 for (zfix ty = y+1; ty < my; ++ty)
7983 {
7984 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
7985
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 568 times.
1258 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
7986 {
7987 568 y = ty;
7988
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 557 times.
568 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
7989 {
7990
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 5 times.
557 if(!slopeid)
7991 5 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
7992 557 onplatid = 5;
7993 557 }
7994 568 needFall = false;
7995 568 break;
7996 }
7997 690 }
7998 581 }
7999 1349 else needFall = true;
8000 // Continue falling.
8001
8002
4/4
✓ Branch 0 taken 5917 times.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 4721 times.
✓ Branch 3 taken 1196 times.
6083 if(fall <= termv && needFall)
8003 {
8004 1196 inair = true;
8005
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1158 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
1196 if(fall != 0 || hoverclk>0)
8006 1158 jumping++;
8007
8008 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
1196 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8010 {
8011 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8012 || (y<=(bigHitbox?9:1) &&
8013 // Extra checks if Smart Screen Scrolling is enabled
8014 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8015 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8016 && fall < 0)
8017 {
8018 fall = jumping = 0; // Bumped his head
8019
8020 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8021 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8022 {
8023 checkdamagecombos(x+4, x+12, y-1, y-1);
8024 }
8025 }
8026 }
8027 else
8028 {
8029
8/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1196 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1196 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1196 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1196 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1196 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1196 times.
✓ Branch 14 taken 1196 times.
✗ Branch 15 not taken.
2392 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8030
3/4
✓ Branch 0 taken 1196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 1165 times.
1196 || ((y<=0) &&
8031 // Extra checks if Smart Screen Scrolling is enabled
8032
2/6
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8033 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8034 && fall < 0)
8035 {
8036 fall = jumping = 0; // Bumped his head
8037 y -= y.getInt()%8; //fix coords
8038 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8039 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8040 {
8041 checkdamagecombos(x+4, x+12, y-1, y-1);
8042 }
8043 }
8044 }
8045
8046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
1196 if(hoverclk > 0)
8047 {
8048 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8049 {
8050 --hoverclk;
8051 }
8052
8053 if(!hoverclk && !ladderx && !laddery)
8054 {
8055 fall += gravity3;
8056 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8057 }
8058 }
8059
5/12
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 551 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1196 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8060 {
8061 int32_t itemid = current_item_id(itype_hoverboots);
8062 if(hoverclk < 0)
8063 hoverclk = -hoverclk;
8064 else
8065 {
8066 fall = jumping = 0;
8067 if(itemsbuf[itemid].misc1)
8068 hoverclk = itemsbuf[itemid].misc1;
8069 else
8070 {
8071 hoverclk = 1;
8072 hoverflags |= HOV_INF;
8073 }
8074
8075
8076 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8077 }
8078 if(itemsbuf[itemid].wpn)
8079 decorations.add(new dHover(x, y, dHOVER, 0));
8080 }
8081
4/8
✓ Branch 0 taken 1196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1196 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1196 times.
1196 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8082 {
8083 1196 fall += gravity3;
8084
8085 1196 }
8086 1196 }
8087 6083 }
8088 else // Topdown gravity
8089 {
8090
3/4
✓ Branch 0 taken 4870882 times.
✓ Branch 1 taken 2435801 times.
✓ Branch 2 taken 2435801 times.
✗ Branch 3 not taken.
7306683 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8091
3/4
✓ Branch 0 taken 4870882 times.
✓ Branch 1 taken 2435801 times.
✓ Branch 2 taken 2435801 times.
✗ Branch 3 not taken.
7306683 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8092
4/4
✓ Branch 0 taken 2435681 times.
✓ Branch 1 taken 4871002 times.
✓ Branch 2 taken 4871122 times.
✓ Branch 3 taken 7306803 times.
7306683 if(z>0||fakez>0)
8093 {
8094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9742124 switch(action)
8095 {
8096 case swimming:
8097 {
8098 diveclk=0;
8099 action=walking; FFCore.setHeroAction(walking);
8100
8101 break;
8102 }
8103 case waterhold1:
8104 {
8105 action=landhold1; FFCore.setHeroAction(landhold1);
8106 break;
8107 }
8108
8109 case waterhold2:
8110 {
8111 action=landhold2; FFCore.setHeroAction(landhold2);
8112 break;
8113 }
8114
8115 default:
8116 120 break;
8117 }
8118 120 }
8119
8120
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 7306923 times.
7308348 for(int32_t j=0; j<chainlinks.Count(); j++)
8121 {
8122 1425 chainlinks.spr(j)->z=z;
8123 1425 chainlinks.spr(j)->fakez=fakez;
8124 1425 }
8125
8126
2/2
✓ Branch 0 taken 7306651 times.
✓ Branch 1 taken 272 times.
7306923 if(Lwpns.idFirst(wHookshot)>-1)
8127 {
8128 272 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8129 272 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8130 272 }
8131
8132
2/2
✓ Branch 0 taken 7306643 times.
✓ Branch 1 taken 280 times.
7306923 if(Lwpns.idFirst(wHSHandle)>-1)
8133 {
8134 280 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8135 280 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8136 280 }
8137
8138
3/4
✓ Branch 0 taken 2435681 times.
✓ Branch 1 taken 4871242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2435681 times.
7306923 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8139 {
8140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2435681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2435681 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8141 {
8142
2/2
✓ Branch 0 taken 2435678 times.
✓ Branch 1 taken 3 times.
2435681 if(fall > 0)
8143 {
8144
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 1 times.
3 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8145 1 sfx(WAV_ZN1SPLASH,x.getInt());
8146
8147 3 stomping = true;
8148 3 }
8149 2435681 }
8150 2435681 z = fall = 0;
8151
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2435681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2435681 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8152 {
8153 2435681 jumping = 0;
8154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2435681 times.
2435681 if(check_pitslide(true) == -1)
8155 {
8156 2435681 hoverclk = 0;
8157 2435681 hoverflags = 0;
8158 2435681 }
8159 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8160 {
8161 if(!--hoverclk)
8162 {
8163 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8164 }
8165 }
8166 2435681 }
8167 2435681 }
8168
3/4
✓ Branch 0 taken 2435801 times.
✓ Branch 1 taken 4871122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2435801 times.
7306923 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8169 {
8170
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2435681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
2435801 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8171 {
8172
1/2
✓ Branch 0 taken 2435681 times.
✗ Branch 1 not taken.
2435681 if(fakefall > 0)
8173 {
8174 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8175 sfx(WAV_ZN1SPLASH,x.getInt());
8176
8177 stomping = true;
8178 }
8179 2435681 }
8180 2435801 fakez = fakefall = 0;
8181
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2435681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
2435801 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8182 {
8183 2435681 jumping = 0;
8184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2435681 times.
2435681 if(check_pitslide(true) == -1)
8185 {
8186 2435681 hoverclk = 0;
8187 2435681 hoverflags = 0;
8188 2435681 }
8189 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8190 {
8191 if(!--hoverclk)
8192 {
8193 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8194 }
8195 }
8196 2435681 }
8197 2435801 }
8198
8/10
✓ Branch 0 taken 2435801 times.
✓ Branch 1 taken 4871122 times.
✓ Branch 2 taken 2435801 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2435561 times.
✓ Branch 5 taken 240 times.
✓ Branch 6 taken 2435681 times.
✓ Branch 7 taken 2435681 times.
✓ Branch 8 taken 2435681 times.
✗ Branch 9 not taken.
7306923 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8199 {
8200
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
4871242 if(fall != 0 || fakefall != 0 || hoverclk>0)
8201 117 jumping++;
8202
8203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(hoverclk > 0)
8204 {
8205 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8206 {
8207 --hoverclk;
8208 }
8209
8210 if(!hoverclk)
8211 {
8212 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8213 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8214 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8215 }
8216 }
8217
9/16
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 117 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 117 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 120 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
120 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8218 {
8219 if(hoverclk < 0)
8220 hoverclk = -hoverclk;
8221 else
8222 {
8223 fall = 0;
8224 fakefall = 0;
8225 int32_t itemid = current_item_id(itype_hoverboots);
8226 if(itemsbuf[itemid].misc1)
8227 hoverclk = itemsbuf[itemid].misc1;
8228 else
8229 {
8230 hoverclk = 1;
8231 hoverflags |= HOV_INF;
8232 }
8233 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8234 }
8235 decorations.add(new dHover(x, y, dHOVER, 0));
8236 }
8237 else
8238 {
8239
3/6
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 120 times.
120 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8240
3/6
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
120 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8241 }
8242 120 }
8243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2435801 times.
2435801 if (fakez<0) fakez = 0;
8244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2435801 times.
2435801 if (z<0) z = 0;
8245 }
8246
8247
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 if(drunkclk)
8248 {
8249 --drunkclk;
8250 }
8251
8252
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 if(lstunclock > 0)
8253 {
8254 // also cancel Hero's attack
8255 attackclk = 0;
8256
8257 if( FFCore.getHeroAction() != stunned )
8258 {
8259 tempaction=action; //update so future checks won't do this
8260 //action=freeze; //setting this makes the player invincible while stunned -V
8261 FFCore.setHeroAction(stunned);
8262 }
8263 --lstunclock;
8264 }
8265 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8266 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2441884 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2441884 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8268 {
8269 action=tempaction; FFCore.setHeroAction(tempaction);
8270 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8271 //action=none; FFCore.setHeroAction(none);
8272 }
8273
8274
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 if( lbunnyclock > 0 )
8275 {
8276 --lbunnyclock;
8277 }
8278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441884 times.
2441884 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8279 {
8280 int32_t itemid = current_item_id(itype_pearl);
8281 if(itemid > -1)
8282 {
8283 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8284 lbunnyclock = 0;
8285 }
8286 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8287 {
8288 lbunnyclock = -1;
8289 }
8290 }
8291
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 else if(lbunnyclock == -1) //dmap-caused bunny effect
8292 {
8293 lbunnyclock = 0;
8294 }
8295
8296
9/16
✓ Branch 0 taken 2440046 times.
✓ Branch 1 taken 1838 times.
✓ Branch 2 taken 2430508 times.
✓ Branch 3 taken 9538 times.
✓ Branch 4 taken 2430508 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2430508 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2430508 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 24297 times.
✓ Branch 15 taken 2406211 times.
2441884 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8297
1/2
✓ Branch 0 taken 2430508 times.
✗ Branch 1 not taken.
2430508 && action != gothit)
8298 {
8299
2/3
✓ Branch 0 taken 1065625 times.
✓ Branch 1 taken 1340586 times.
✗ Branch 2 not taken.
2406211 switch(dir)
8300 {
8301 case up:
8302 case down:
8303 1065625 x=(x.getInt()+4)&0xFFF8;
8304 1065625 break;
8305
8306 case left:
8307 case right:
8308 1340586 y=(y.getInt()+4)&0xFFF8;
8309 1340586 break;
8310 }
8311 2406211 }
8312
8313
4/4
✓ Branch 0 taken 59414 times.
✓ Branch 1 taken 2382470 times.
✓ Branch 2 taken 47892 times.
✓ Branch 3 taken 11522 times.
2441884 if((watch==true) && clockclk)
8314 {
8315 11522 --clockclk;
8316
8317
2/2
✓ Branch 0 taken 11493 times.
✓ Branch 1 taken 29 times.
11522 if(!clockclk)
8318 {
8319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(cheat_superman==false)
8320 {
8321 29 setClock(false);
8322 29 }
8323
8324 29 watch=false;
8325
8326
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 29 times.
14877 for(int32_t i=0; i<eMAXGUYS; i++)
8327 {
8328
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 14848 times.
14851 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8329 {
8330 3 addenemy(0,0,i,0);
8331 3 }
8332 14848 }
8333 29 }
8334 11522 }
8335
8336
3/4
✓ Branch 0 taken 2441604 times.
✓ Branch 1 taken 280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2441604 times.
2441884 if(hookshot_frozen || switch_hooked)
8337 {
8338
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
280 if(hookshot_used || switch_hooked)
8339 {
8340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8341 272 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8342
8343
3/4
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 206 times.
272 if(pull_hero || switch_hooked)
8344 {
8345
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 if(hs_switcher || switch_hooked)
8346 {
8347 hs_fix = false;
8348 if(switchhookclk)
8349 {
8350 --switchhookclk;
8351 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8352 {
8353 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8354 reset_hookshot();
8355 else
8356 {
8357 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8358 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8359
8360 if(hooked_combopos > -1) //Switching combos
8361 {
8362 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8363 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8364 {
8365 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8366 for(int q = max_layer; q > -1; --q)
8367 {
8368 if(!(hooked_layerbits & (1<<q)))
8369 continue; //non-switching layer
8370 mapscr* scr = FFCore.tempScreens[q];
8371 newcombo const& cmb = combobuf[scr->data[targpos]];
8372 int32_t srcfl = scr->sflag[targpos];
8373 newcombo const& comb2 = combobuf[scr->data[plpos]];
8374 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8375 //{Check push status
8376 bool isFakePush = false;
8377 if(cmb.type == cSWITCHHOOK)
8378 {
8379 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8380 isFakePush = true;
8381 }
8382 bool isPush = isFakePush;
8383 if(!isPush) switch(srcfl)
8384 {
8385 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8386 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8387 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8388 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8389 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8390 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8391 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8392 isPush = true;
8393 }
8394 if(!isPush) switch(cmb.flag)
8395 {
8396 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8397 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8398 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8399 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8400 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8401 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8402 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8403 isPush = true;
8404 }
8405 if(srcfl==mfPUSHED) isPush = false;
8406 //}
8407 if(cmb.type == cSWITCHHOOK) //custom flags and such
8408 {
8409 if(cmb.usrflags&cflag3) //Breaks on swap
8410 {
8411 int32_t it = -1;
8412 int32_t thedropset = -1;
8413 if(cmb.usrflags&cflag4) //drop item
8414 {
8415 if(cmb.usrflags&cflag5)
8416 it = cmb.attribytes[2];
8417 else
8418 {
8419 it = select_dropitem(cmb.attribytes[2]);
8420 thedropset = cmb.attribytes[2];
8421 }
8422 }
8423
8424 breakable* br = new breakable(x, y, zfix(0),
8425 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8426 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8427 br->switch_hooked = true;
8428 decorations.add(br);
8429 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8430 hooked_undercombos[q] = -1;
8431
8432 if(cmb.usrflags&cflag6)
8433 {
8434 scr->data[targpos]++;
8435 }
8436 else
8437 {
8438 scr->data[targpos] = scr->undercombo;
8439 scr->cset[targpos] = scr->undercset;
8440 if(cmb.usrflags&cflag2)
8441 scr->sflag[targpos] = 0;
8442 }
8443 }
8444 else if(isPush)
8445 {
8446 //Simulate a block clicking into place
8447 movingblock mtemp;
8448 mtemp.clear();
8449 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8450 mtemp.dir = getPushDir(scr->sflag[targpos]);
8451 if(mtemp.dir < 0)
8452 mtemp.dir = getPushDir(cmb.flag);
8453 mtemp.clk = 1;
8454 if(isFakePush)
8455 mtemp.force_many = true;
8456 mtemp.animate(0);
8457 if((mtemp.bhole || mtemp.trigger)
8458 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8459 || comb2.flag == mfBLOCKTRIGGER
8460 || comb2.flag == mfBLOCKHOLE))
8461 {
8462 scr->data[targpos] = scr->undercombo;
8463 scr->cset[targpos] = scr->undercset;
8464 scr->sflag[targpos] = 0;
8465 }
8466 else
8467 {
8468 scr->data[targpos] = c;
8469 scr->cset[targpos] = cs;
8470 if(cmb.usrflags&cflag2)
8471 scr->sflag[targpos] = fl;
8472 else
8473 scr->sflag[targpos] = 0;
8474 }
8475 }
8476 else
8477 {
8478 scr->data[plpos] = scr->data[targpos];
8479 scr->cset[plpos] = scr->cset[targpos];
8480 if(cmb.usrflags&cflag2)
8481 scr->sflag[plpos] = scr->sflag[targpos];
8482 scr->data[targpos] = c;
8483 scr->cset[targpos] = cs;
8484 if(cmb.usrflags&cflag2)
8485 scr->sflag[targpos] = fl;
8486 }
8487 }
8488 else if(isCuttableType(cmb.type)) //Break and drop effects
8489 {
8490 int32_t breakcs = scr->cset[targpos];
8491 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8492 {
8493 scr->data[targpos]++;
8494 }
8495 else
8496 {
8497 scr->data[targpos] = scr->undercombo;
8498 scr->cset[targpos] = scr->undercset;
8499 scr->sflag[targpos] = 0;
8500 }
8501
8502 int32_t it = -1;
8503 int32_t thedropset = -1;
8504 if(isCuttableItemType(cmb.type)) //Drop an item
8505 {
8506 if ( (cmb.usrflags&cflag2) )
8507 {
8508 if(cmb.usrflags&cflag11)
8509 it = cmb.attribytes[1];
8510 else
8511 {
8512 it = select_dropitem(cmb.attribytes[1]);
8513 thedropset = cmb.attribytes[1];
8514 }
8515 }
8516 else
8517 {
8518 it = select_dropitem(12);
8519 thedropset = 12;
8520 }
8521 }
8522
8523 byte breaksfx = 0;
8524 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8525 {
8526 if (cmb.usrflags&cflag3)
8527 {
8528 breaksfx = cmb.attribytes[2];
8529 }
8530 else if(isBushType(cmb.type)
8531 || isFlowersType(cmb.type)
8532 || isGrassType(cmb.type))
8533 {
8534 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8535 }
8536 }
8537
8538 //Clipping sprite
8539 int16_t decotype = (cmb.usrflags & cflag1) ?
8540 ((cmb.usrflags & cflag10)
8541 ? (cmb.attribytes[0])
8542 : (-1))
8543 : (0);
8544 if(decotype > 3) decotype = 0;
8545 if(!decotype)
8546 decotype = (isBushType(cmb.type) ? 1
8547 : (isFlowersType(cmb.type) ? 2
8548 : (isGrassType(cmb.type) ? 3
8549 : ((cmb.usrflags & cflag1) ? -1
8550 : -2))));
8551
8552 breakable* br = new breakable(x, y, zfix(0),
8553 cmb, breakcs, it, thedropset, breaksfx,
8554 decotype, cmb.attribytes[0], switchhookclk);
8555 br->switch_hooked = true;
8556 decorations.add(br);
8557 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8558 hooked_undercombos[q] = -1;
8559 }
8560 else //Unknown type, just swap combos.
8561 {
8562 if(isPush)
8563 {
8564 //Simulate a block clicking into place
8565 movingblock mtemp;
8566 mtemp.clear();
8567 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8568 mtemp.dir = getPushDir(scr->sflag[targpos]);
8569 if(mtemp.dir < 0)
8570 mtemp.dir = getPushDir(cmb.flag);
8571 mtemp.clk = 1;
8572 mtemp.animate(0);
8573 if(mtemp.bhole || mtemp.trigger)
8574 {
8575 scr->data[targpos] = scr->undercombo;
8576 scr->cset[targpos] = scr->undercset;
8577 scr->sflag[targpos] = 0;
8578 }
8579 else
8580 {
8581 scr->data[targpos] = c;
8582 scr->cset[targpos] = cs;
8583 scr->sflag[targpos] = 0;
8584 }
8585 }
8586 else
8587 {
8588 scr->data[plpos] = scr->data[targpos];
8589 scr->cset[plpos] = scr->cset[targpos];
8590 scr->data[targpos] = c;
8591 scr->cset[targpos] = cs;
8592 }
8593 }
8594 }
8595 if(switchhook_cost_item > -1)
8596 paymagiccost(switchhook_cost_item);
8597 zfix tx = x, ty = y;
8598 //Position the player at the combo
8599 x = COMBOX(targpos);
8600 y = COMBOY(targpos);
8601 dir = oppositeDir[dir];
8602 if(w && hw)
8603 {
8604 //Calculate chain shift
8605 zfix dx = (x-tx);
8606 zfix dy = (y-ty);
8607 if(w->dir < 4)
8608 {
8609 if(w->dir & 2)
8610 dx = 0;
8611 else dy = 0;
8612 }
8613 //Position the hook head at the handle
8614 w->x = hw->x + dx;
8615 w->y = hw->y + dy;
8616 w->dir = oppositeDir[w->dir];
8617 w->doAutoRotate(true);
8618 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8619 w->flip ^= hflip;
8620 //Position the handle appropriately
8621 hw->x = x-(hw->x-tx);
8622 hw->y = y-(hw->y-ty);
8623 hw->dir = oppositeDir[hw->dir];
8624 hw->doAutoRotate(true);
8625 hw->flip ^= hflip;
8626 //Move chains
8627 for(int32_t j=0; j<chainlinks.Count(); j++)
8628 {
8629 chainlinks.spr(j)->x += dx;
8630 chainlinks.spr(j)->y += dy;
8631 }
8632 }
8633 hooked_combopos = plpos; //flip positions
8634 }
8635 else reset_hookshot();
8636 }
8637 else if(switching_object) //Switching an object
8638 {
8639 if(switchhook_cost_item > -1)
8640 paymagiccost(switchhook_cost_item);
8641 zfix tx = x, ty = y;
8642 //Position the player at the object
8643 x = switching_object->x;
8644 y = switching_object->y;
8645 dir = oppositeDir[dir];
8646 //Position the object at the player
8647 switching_object->x = tx;
8648 switching_object->y = ty;
8649 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8650 switching_object->dir = oppositeDir[switching_object->dir];
8651 solid_update(false);
8652 switching_object->solid_update(false);
8653 if(item* it = dynamic_cast<item*>(switching_object))
8654 {
8655 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8656 {
8657 movefairynew2(it->x, it->y, *it);
8658 }
8659 }
8660 if(w && hw) //!TODO No fucking clue if diagonals work
8661 {
8662 //Calculate chain shift
8663 zfix dx = (x-tx);
8664 zfix dy = (y-ty);
8665 if(w->dir < 4)
8666 {
8667 if(w->dir & 2)
8668 dx = 0;
8669 else dy = 0;
8670 }
8671 //Position the hook head at the handle
8672 w->x = hw->x + dx;
8673 w->y = hw->y + dy;
8674 w->dir = oppositeDir[w->dir];
8675 w->doAutoRotate(true);
8676 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8677 w->flip ^= hflip;
8678 w->solid_update(false);
8679 //Position the handle appropriately
8680 hw->x = x-(hw->x-tx);
8681 hw->y = y-(hw->y-ty);
8682 hw->dir = oppositeDir[hw->dir];
8683 hw->doAutoRotate(true);
8684 hw->flip ^= hflip;
8685 hw->solid_update(false);
8686 //Move chains
8687 for(int32_t j=0; j<chainlinks.Count(); j++)
8688 {
8689 chainlinks.spr(j)->x += dx;
8690 chainlinks.spr(j)->y += dy;
8691 }
8692 }
8693 }
8694 }
8695 }
8696 else if(!switchhookclk)
8697 {
8698 reset_hookshot();
8699 }
8700 }
8701 else reset_hookshot();
8702 }
8703 else
8704 {
8705 sprite *t;
8706 int32_t i;
8707
8708
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8709 {
8710 /* do nothing */
8711 }
8712
8713 66 t = Lwpns.spr(i);
8714
8715
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 66 times.
198 for(i=0; i<Lwpns.Count(); i++)
8716 {
8717 132 sprite *s = Lwpns.spr(i);
8718
8719
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 66 times.
132 if(s->id==wHookshot)
8720 {
8721
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 45 times.
66 if (abs((s->y) - y) >= 1)
8722 {
8723
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 10 times.
21 if((s->y)>y)
8724 {
8725 10 y+=4;
8726
8727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Lwpns.idFirst(wHSHandle)!=-1)
8728 {
8729 10 t->y+=4;
8730 10 }
8731
8732 10 hs_starty+=4;
8733 10 }
8734
8735
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11 times.
21 if((s->y)<y)
8736 {
8737 11 y-=4;
8738
8739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Lwpns.idFirst(wHSHandle)!=-1)
8740 {
8741 11 t->y-=4;
8742 11 }
8743
8744 11 hs_starty-=4;
8745 11 }
8746 21 }
8747 else
8748 {
8749 45 y = (s->y);
8750 }
8751
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 21 times.
66 if (abs((s->x) - x) >= 1)
8752 {
8753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if((s->x)>x)
8754 {
8755 45 x+=4;
8756
8757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(Lwpns.idFirst(wHSHandle)!=-1)
8758 {
8759 45 t->x+=4;
8760 45 }
8761
8762 45 hs_startx+=4;
8763 45 }
8764
8765
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if((s->x)<x)
8766 {
8767 x-=4;
8768
8769 if(Lwpns.idFirst(wHSHandle)!=-1)
8770 {
8771 t->x-=4;
8772 }
8773
8774 hs_startx-=4;
8775 }
8776 45 }
8777 else
8778 {
8779 21 x = (s->x);
8780 }
8781 66 }
8782 132 }
8783 }
8784 66 }
8785 272 }
8786 else
8787 {
8788 8 Lwpns.del(Lwpns.idFirst(wHSHandle));
8789 8 reset_hookshot();
8790 }
8791
8792
1/2
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
280 if(hs_fix)
8793 {
8794 if(dir==up)
8795 {
8796 y=int32_t(y+7)&0xF0;
8797 }
8798
8799 if(dir==down)
8800 {
8801 y=int32_t(y+7)&0xF0;
8802 }
8803
8804 if(dir==left)
8805 {
8806 x=int32_t(x+7)&0xF0;
8807 }
8808
8809 if(dir==right)
8810 {
8811 x=int32_t(x+7)&0xF0;
8812 }
8813
8814 hs_fix=false;
8815 }
8816
8817 280 }
8818
8819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441884 times.
2441884 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8820 {
8821
2/2
✓ Branch 0 taken 1006 times.
✓ Branch 1 taken 2440878 times.
2441884 if(DrunkrLbtn())
8822 1006 selectNextBWpn(SEL_LEFT);
8823
2/2
✓ Branch 0 taken 2439565 times.
✓ Branch 1 taken 1313 times.
2440878 else if(DrunkrRbtn())
8824 1313 selectNextBWpn(SEL_RIGHT);
8825 2441884 }
8826
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2441884 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2441884 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8827 {
8828 if (rEx3btn())
8829 selectNextAWpn(SEL_LEFT);
8830 else if (rEx4btn())
8831 selectNextAWpn(SEL_RIGHT);
8832 }
8833
8834
2/2
✓ Branch 0 taken 2441883 times.
✓ Branch 1 taken 1 times.
2441884 if(rPbtn())
8835 {
8836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8837 1 onViewMap();
8838 1 }
8839
2/2
✓ Branch 0 taken 1183295 times.
✓ Branch 1 taken 2441884 times.
3625179 for(int32_t i=0; i<Lwpns.Count(); i++)
8840 {
8841 1183295 weapon *w = ((weapon*)Lwpns.spr(i));
8842
8843
5/6
✓ Branch 0 taken 1179159 times.
✓ Branch 1 taken 4136 times.
✓ Branch 2 taken 1040822 times.
✓ Branch 3 taken 138337 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1040822 times.
1183295 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8844 142473 addsparkle(i);
8845 1183295 }
8846
8847
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 if(Lwpns.idCount(wPhantom))
8848 {
8849 addsparkle2(pDINSFIREROCKET,pDINSFIREROCKETTRAIL);
8850 addsparkle2(pDINSFIREROCKETRETURN,pDINSFIREROCKETTRAILRETURN);
8851 addsparkle2(pNAYRUSLOVEROCKET1,pNAYRUSLOVEROCKETTRAIL1);
8852 addsparkle2(pNAYRUSLOVEROCKET2,pNAYRUSLOVEROCKETTRAIL2);
8853 addsparkle2(pNAYRUSLOVEROCKETRETURN1,pNAYRUSLOVEROCKETTRAILRETURN1);
8854 addsparkle2(pNAYRUSLOVEROCKETRETURN2,pNAYRUSLOVEROCKETTRAILRETURN2);
8855 }
8856
8857 // Pay magic cost for Byrna beams
8858
8859 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8860
1/2
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
2441884 if(Lwpns.idCount(wCByrna))
8861 {
8862 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8863 int32_t itemid = ew->parentitem;
8864
8865 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8866 {
8867 for(int32_t i=0; i<Lwpns.Count(); i++)
8868 {
8869 weapon *w = ((weapon*)Lwpns.spr(i));
8870
8871 if(w->id==wCByrna)
8872 {
8873 w->dead=1;
8874 }
8875
8876 }
8877 //kill the sound effect for the orbits -Z 14FEB2019
8878 stop_sfx(itemsbuf[itemid].usesound);
8879 }
8880 else paymagiccost(itemid);
8881 }
8882
8883
3/4
✓ Branch 0 taken 2441764 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 2441764 times.
✗ Branch 3 not taken.
2441884 if(z==0&&fakez==0)
8884 {
8885 2441764 switchblock_z = 0;
8886
1/2
✓ Branch 0 taken 2441764 times.
✗ Branch 1 not taken.
2441764 if(switchblock_offset)
8887 {
8888 switchblock_offset=false;
8889 yofs += 8;
8890 }
8891 2441764 }
8892
2/2
✓ Branch 0 taken 6083 times.
✓ Branch 1 taken 2435801 times.
2441884 if(!isSideViewHero())
8893 {
8894 2435801 int32_t tx = x.getInt()+8,
8895 2435801 ty = y.getInt()+8;//(bigHitbox?8:12);
8896
4/4
✓ Branch 0 taken 2435686 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 2435586 times.
2435801 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8897 {
8898
2/2
✓ Branch 0 taken 2435586 times.
✓ Branch 1 taken 7306758 times.
9742344 for(int32_t q = 0; q < 3; ++q)
8899 {
8900
4/4
✓ Branch 0 taken 4871172 times.
✓ Branch 1 taken 2435586 times.
✓ Branch 2 taken 514452 times.
✓ Branch 3 taken 4356720 times.
7306758 if(q && !tmpscr2[q-1].valid) continue;
8901 2950038 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2950038 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2950038 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8903 int32_t b = 1;
8904 if(tx&8) b <<= 2;
8905 if(ty&8) b <<= 1;
8906 b |= (b<<4); //check equivalent effect flag too
8907 if((cmb.walk&b)==b) //solid and effecting
8908 {
8909 if(z==0&&fakez==0)
8910 {
8911 if(cmb.usrflags&cflag10)
8912 {
8913 if(!switchblock_offset)
8914 {
8915 switchblock_offset=true;
8916 yofs -= 8;
8917 }
8918 }
8919 else
8920 {
8921 if(switchblock_offset)
8922 {
8923 switchblock_offset=false;
8924 yofs += 8;
8925 }
8926 }
8927 }
8928 if(cmb.attributes[2]>0 && switchblock_z>=0)
8929 {
8930 if(z==0&&fakez==0)
8931 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8932 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8933 {
8934 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8935 }
8936 }
8937 else switchblock_z = -1;
8938 break;
8939 }
8940 }
8941 2435586 }
8942 2435801 }
8943 2441884 ClearhitHeroUIDs(); //clear them before we advance.
8944 2441884 checkhit();
8945
8946 2441884 bool forcedeath = dying_flags&DYING_FORCED;
8947 2441884 bool norev = (dying_flags&DYING_NOREV);
8948
4/6
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 2441868 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
2441884 if(forcedeath || (game->get_life()<=0 && !immortal))
8949 {
8950
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(forcedeath)
8951 game->set_life(0);
8952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!norev)
8953
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(size_t slot = 0; slot < 256; ++slot)
8954 {
8955
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(size_t bind = game->get_bottle_slot(slot))
8956 {
8957 bottletype const* bt = &QMisc.bottle_types[bind-1];
8958 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8959 continue;
8960 word toFill[3] = { 0 };
8961 for(size_t q = 0; q < 3; ++q)
8962 {
8963 char c = bt->counter[q];
8964 if(c > -1)
8965 {
8966 if(bt->flags & (1<<q))
8967 {
8968 toFill[q] = (bt->amount[q]==100)
8969 ? game->get_maxcounter(c)
8970 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
8971 }
8972 else toFill[q] = bt->amount[q];
8973 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
8974 {
8975 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
8976 }
8977 }
8978 }
8979 if(bt->flags & BTFLAG_CURESWJINX)
8980 {
8981 swordclk = 0;
8982 verifyAWpn();
8983 }
8984 if(bt->flags & BTFLAG_CUREITJINX)
8985 itemclk = 0;
8986 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
8987 {
8988 int32_t itemid = find_bottle_for_slot(slot,true);
8989 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
8990 if(itemid > -1)
8991 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8992 for(size_t q = 0; q < 20; ++q)
8993 do_death_refill_waitframe();
8994 double inc = max/60.0; //1 second
8995 double xtra[3]{ 0 };
8996 for(size_t q = 0; q < 60; ++q)
8997 {
8998 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
8999 sfx(QMisc.miscsfx[sfxREFILL]);
9000 for(size_t j = 0; j < 3; ++j)
9001 {
9002 xtra[j] += inc;
9003 word f = floor(xtra[j]);
9004 xtra[j] -= f;
9005 if(toFill[j] > f)
9006 {
9007 toFill[j] -= f;
9008 game->change_counter(f,bt->counter[j]);
9009 }
9010 else if(toFill[j])
9011 {
9012 game->change_counter(toFill[j],bt->counter[j]);
9013 toFill[j] = 0;
9014 }
9015 }
9016 do_death_refill_waitframe();
9017 }
9018 for(size_t j = 0; j < 3; ++j)
9019 {
9020 if(toFill[j])
9021 {
9022 game->change_counter(toFill[j],bt->counter[j]);
9023 toFill[j] = 0;
9024 }
9025 }
9026 for(size_t q = 0; q < 20; ++q)
9027 do_death_refill_waitframe();
9028 }
9029 game->set_bottle_slot(slot,bt->next_type);
9030 if(game->get_life() > 0)
9031 {
9032 dying_flags = 0;
9033 forcedeath = false;
9034 break; //Revived! Stop drinking things...
9035 }
9036 }
9037 4112 }
9038
9039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9040 {
9041 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9042 {
9043 // So scripts can have one frame to handle hp zero events
9044 if(norev || false == (last_hurrah = !last_hurrah))
9045 {
9046 dying_flags = 0;
9047 drunkclk=0;
9048 lstunclock = 0;
9049 is_conveyor_stunned = 0;
9050 FFCore.setHeroAction(dying);
9051 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
9052 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
9053 ALLOFF(true,true);
9054 GameFlags |= GAMEFLAG_NO_F6;
9055 if(!debug_enabled)
9056 {
9057 Paused=false;
9058 }
9059 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9060 {
9061 FFCore.runOnDeathEngine();
9062 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9063 }
9064 Playing = false;
9065 heroDeathAnimation();
9066 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9067 {
9068 Playing = true;
9069 FFCore.runOnDeathEngine();
9070 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9071 Playing = false;
9072 }
9073 GameFlags &= ~GAMEFLAG_NO_F6;
9074 ALLOFF(true,true);
9075 return true;
9076 }
9077 }
9078 }
9079 else //2.50.x
9080 {
9081 // So scripts can have one frame to handle hp zero events
9082
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 if(false == (last_hurrah = !last_hurrah))
9083 {
9084 8 drunkclk=0;
9085 8 heroDeathAnimation();
9086
9087 8 return true;
9088 }
9089 }
9090 8 }
9091 2441868 else last_hurrah=false;
9092
9093
2/2
✓ Branch 0 taken 16680 times.
✓ Branch 1 taken 2425196 times.
2441876 if(swordclk>0)
9094 {
9095 16680 --swordclk;
9096
2/2
✓ Branch 0 taken 16594 times.
✓ Branch 1 taken 86 times.
16680 if(!swordclk) verifyAWpn();
9097 16680 }
9098
2/2
✓ Branch 0 taken 3344 times.
✓ Branch 1 taken 2438532 times.
2441876 if(itemclk>0)
9099 3344 --itemclk;
9100
9101
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 2441647 times.
2441876 if(inwallm)
9102 {
9103 229 attackclk=0;
9104 229 herostep();
9105
9106
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 2 times.
229 if(CarryHero()==false)
9107 2 restart_level();
9108
9109 229 solid_update(false);
9110 229 return false;
9111 }
9112
9113
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2441646 times.
2441647 if(ewind_restart)
9114 {
9115 1 attackclk=0;
9116 1 restart_level();
9117 1 xofs=0;
9118 1 action=none; FFCore.setHeroAction(none);
9119 1 ewind_restart=false;
9120 1 solid_update(false);
9121 1 return false;
9122 }
9123
9124
2/2
✓ Branch 0 taken 2440882 times.
✓ Branch 1 taken 764 times.
2441646 if(hopclk)
9125 {
9126 764 action=hopping; FFCore.setHeroAction(hopping);
9127 764 }
9128
1/2
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
2441646 if(fallclk)
9129 {
9130 action=falling; FFCore.setHeroAction(falling);
9131 }
9132
9133 2441646 handle_passive_buttons();
9134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441646 times.
2441646 if(liftclk)
9135 {
9136 if(lift_wpn)
9137 {
9138 action=lifting; FFCore.setHeroAction(lifting);
9139 }
9140 else
9141 {
9142 liftclk = 0;
9143 tliftclk = 0;
9144 }
9145 }
9146
1/2
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
2441646 else if(lift_wpn)
9147 {
9148 handle_lift(false);
9149 }
9150
9151
9152 // get user input or do other animation
9153 2441646 freeze_guys=false; // reset this flag, set it again if holding
9154
9155
13/16
✓ Branch 0 taken 2422750 times.
✓ Branch 1 taken 18896 times.
✓ Branch 2 taken 2415992 times.
✓ Branch 3 taken 6758 times.
✓ Branch 4 taken 2415732 times.
✓ Branch 5 taken 260 times.
✓ Branch 6 taken 2415732 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2415732 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2415732 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2406029 times.
✓ Branch 13 taken 9703 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 2406025 times.
2441646 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9156 {
9157 4 holdclk=0;
9158 4 }
9159
9160 2441646 active_shield_id = refreshActiveShield();
9161 2441646 bool sh = active_shield_id > -1;
9162 2441646 itemdata const& shield = itemsbuf[active_shield_id];
9163 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9164 2441646 shield_forcedir = -1;
9165
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2441646 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2441646 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9166 {
9167 shield_forcedir = dir;
9168 }
9169
1/2
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
2441646 if(sh != shield_active) //Toggle active shield on/off
9170 {
9171 shield_active = sh;
9172 if(sh) //Toggle active shield on
9173 {
9174 sfx(shield.usesound2); //'Activate' sfx
9175 }
9176 }
9177
9178 2441646 bool isthissolid = false;
9179
9/12
✓ Branch 0 taken 11141 times.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 42604 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25654 times.
✓ Branch 6 taken 2333694 times.
✓ Branch 7 taken 24366 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 764 times.
✓ Branch 10 taken 2971 times.
✗ Branch 11 not taken.
2441646 switch(action)
9180 {
9181 case gothit:
9182
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 23648 times.
24366 if(attackclk)
9183
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 86 times.
804 if(!doattack())
9184 {
9185 86 attackclk=spins=0;
9186 86 tapping=false;
9187 86 }
9188
9189 24366 break;
9190
9191 case drowning:
9192 case lavadrowning:
9193 case sidedrowning:
9194 {
9195 192 herostep(); // maybe this line should be elsewhere?
9196
9197 //!DROWN
9198 // Helpful comment to find drowning -Dimi
9199
9200 192 drop_liftwpn();
9201
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 3 times.
192 if(--drownclk==0)
9202 {
9203 3 action=none; FFCore.setHeroAction(none);
9204 3 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9205 3 int32_t damage = combobuf[water].attributes[0]/10000L;
9206 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9207 3 drownCombo = 0;
9208
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (combobuf[water].type != cWATER) damage = 4;
9209 3 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9210 3 go_respawn_point();
9211 3 hclk=48;
9212 3 }
9213
9214 192 break;
9215 }
9216 case falling:
9217 {
9218 herostep();
9219 pitfall();
9220 break;
9221 }
9222 case freeze:
9223 case sideswimfreeze:
9224 case scrolling:
9225 42604 break;
9226
9227 case casting:
9228 case sideswimcasting:
9229 {
9230 if(magicitem==-1)
9231 {
9232 action=none; FFCore.setHeroAction(none);
9233 }
9234
9235 break;
9236 }
9237 case landhold1:
9238 case landhold2:
9239 {
9240
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 25471 times.
25654 if(--holdclk <= 0)
9241 {
9242 //restart music
9243
4/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 7 times.
183 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9244 7 playLevelMusic();
9245
9246 183 action=none; FFCore.setHeroAction(none);
9247 183 }
9248 else
9249 25471 freeze_guys=true;
9250
9251 25654 break;
9252 }
9253 case waterhold1:
9254 case waterhold2:
9255 case sidewaterhold1:
9256 case sidewaterhold2:
9257 {
9258 260 diveclk=0;
9259
9260
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 258 times.
260 if(--holdclk <= 0)
9261 {
9262 //restart music
9263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9264 playLevelMusic();
9265
9266 2 SetSwim();
9267 2 }
9268 else
9269 258 freeze_guys=true;
9270
9271 260 break;
9272 }
9273 case hopping:
9274 {
9275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
764 if(DRIEDLAKE)
9276 {
9277 action=none; FFCore.setHeroAction(none);
9278 hopclk = 0;
9279 diveclk = 0;
9280 break;
9281 }
9282
9283 764 do_hopping();
9284 764 break;
9285 }
9286 case inwind:
9287 {
9288 2971 int32_t i=Lwpns.idFirst(wWind);
9289
9290
2/2
✓ Branch 0 taken 2930 times.
✓ Branch 1 taken 41 times.
2971 if(i<0)
9291 {
9292 41 bool exit=false;
9293
9294
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 21 times.
41 if(whirlwind==255)
9295 {
9296 20 exit=true;
9297 20 }
9298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(y<=0 && dir==up) y=-1;
9299
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(y>=160 && dir==down) y=161;
9300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(x<=0 && dir==left) x=-1;
9301
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 else if(x>=240 && dir==right) x=241;
9302 else exit=true;
9303
9304
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 if(exit)
9305 {
9306 20 action=none; FFCore.setHeroAction(none);
9307 20 xofs=0;
9308 20 whirlwind=0;
9309 20 lstep=0;
9310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if ( dontdraw < 2 ) dontdraw=0;
9311 20 set_respawn_point();
9312 20 }
9313 41 }
9314 /*
9315 else if (((weapon*)Lwpns.spr(i))->dead==1)
9316 {
9317 whirlwind=255;
9318 }
9319 */
9320 else
9321 {
9322 2930 x=Lwpns.spr(i)->x;
9323 2930 y=Lwpns.spr(i)->y;
9324 2930 dir=Lwpns.spr(i)->dir;
9325 }
9326 }
9327 2971 break;
9328 case lifting:
9329 handle_lift();
9330 break;
9331
9332 case sideswimming:
9333 case sideswimattacking:
9334 case sideswimhit:
9335 case swimhit:
9336 case swimming:
9337 {
9338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11141 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11141 if(DRIEDLAKE)
9339 {
9340 action=none; FFCore.setHeroAction(none);
9341 hopclk=0;
9342 break;
9343 }
9344
9345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11141 times.
11141 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9346
9347
4/4
✓ Branch 0 taken 5561 times.
✓ Branch 1 taken 5580 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5541 times.
11141 if((frame&1) && !shouldbreak)
9348 5541 herostep();
9349
9350
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11141 times.
✓ Branch 4 taken 406 times.
✓ Branch 5 taken 10735 times.
11547 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9351
4/6
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 406 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 406 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 406 times.
11141 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9352
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 406 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 406 times.
406 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 406 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 406 times.
11141 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9354
2/4
✓ Branch 0 taken 11141 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11141 times.
✗ Branch 3 not taken.
11141 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9355 {
9356 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9357 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9358 {
9359 hopclk=0;
9360 diveclk=0;
9361 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9362 else {action=attacking; FFCore.setHeroAction(attacking);}
9363 hopdir=-1;
9364 }
9365 }
9366
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 11101 times.
11141 if (shouldbreak) break;
9367
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11101 if (action == swimming || action == sideswimming || action == sideswimattacking)
9368 {
9369 11101 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11101 times.
11101 if (combobuf[watercheck].usrflags&cflag2)
9371 {
9372 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9373 {
9374 onpassivedmg = true;
9375 if (damageovertimeclk == 0)
9376 {
9377 int32_t curhp = game->get_life();
9378 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9379 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9380 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9381 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9382 {
9383 hclk = 48;
9384 hitdir = -1;
9385 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9386 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9387 }
9388 }
9389 if (combobuf[watercheck].attribytes[1] > 0)
9390 {
9391 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9392 else --damageovertimeclk;
9393 }
9394 else damageovertimeclk = 0;
9395 }
9396 else damageovertimeclk = 0;
9397 }
9398 11101 else damageovertimeclk = 0;
9399 //combobuf[watercheck].attributes[0]
9400 11101 }
9401
9402 11101 }
9403 [[fallthrough]];
9404 default:
9405 2344795 movehero(); // call the main movement routine
9406 2344795 }
9407
9408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2441646 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2441646 if(shield_forcedir > -1 && action != rafting)
9409 dir = shield_forcedir;
9410
9411
2/2
✓ Branch 0 taken 2432108 times.
✓ Branch 1 taken 9538 times.
2441646 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9412 9538 set_respawn_point(false); //Keep the 'last safe location' updated!
9413
9414 // check for ladder removal
9415
2/2
✓ Branch 0 taken 9538 times.
✓ Branch 1 taken 2432108 times.
2441646 if(diagonalMovement)
9416 {
9417
1/2
✓ Branch 0 taken 9538 times.
✗ Branch 1 not taken.
9538 if(ladderx+laddery)
9418 {
9419 if(ladderdir==up)
9420 {
9421 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9422 {
9423 reset_ladder();
9424 }
9425 }
9426 else
9427 {
9428 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9429 {
9430 reset_ladder();
9431 }
9432 }
9433 }
9434 9538 }
9435 else
9436 {
9437
4/4
✓ Branch 0 taken 72385 times.
✓ Branch 1 taken 2359723 times.
✓ Branch 2 taken 24664 times.
✓ Branch 3 taken 47721 times.
2432108 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9438 {
9439 2384387 reset_ladder();
9440 2384387 }
9441 }
9442
9443
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 2441513 times.
2441646 if(ilswim)
9444 133 landswim++;
9445 2441513 else landswim=0;
9446
9447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441646 times.
2441646 if(hopclk!=0xFF) ilswim=false;
9448
9449
3/4
✓ Branch 0 taken 4397 times.
✓ Branch 1 taken 2437249 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4397 times.
2441646 if((!loaded_guys) && (frame - newscr_clk >= 1))
9450 {
9451
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4394 times.
4397 if(tmpscr->room==rGANON)
9452 {
9453 3 ganon_intro();
9454 3 }
9455 else
9456 {
9457 4394 loadguys();
9458 }
9459 4397 }
9460
9461
2/2
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 2437064 times.
2441646 if(frame - newscr_clk >= 2)
9462 {
9463 2437064 loadenemies();
9464 2437064 }
9465
9466 // check lots of other things
9467 2441646 checkscroll();
9468
9469
6/8
✓ Branch 0 taken 2438696 times.
✓ Branch 1 taken 2950 times.
✓ Branch 2 taken 2438507 times.
✓ Branch 3 taken 189 times.
✓ Branch 4 taken 2438507 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2438507 times.
2441646 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9470 {
9471 2438507 checkspecial();
9472 2438507 checkitems();
9473 2438507 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9474
2/2
✓ Branch 0 taken 9349 times.
✓ Branch 1 taken 2429158 times.
2438507 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9475 {
9476 2429158 oldchecklockblock();
9477 2429158 oldcheckbosslockblock();
9478 2429158 }
9479
2/2
✓ Branch 0 taken 9349 times.
✓ Branch 1 taken 2429158 times.
2438507 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9480 {
9481 2429158 oldcheckchest(cCHEST);
9482 2429158 oldcheckchest(cLOCKEDCHEST);
9483 2429158 oldcheckchest(cBOSSCHEST);
9484 2429158 }
9485 2438507 checkpushblock();
9486 2438507 checkswordtap();
9487
9488
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 2438227 times.
2438507 if(hookshot_frozen==false)
9489 {
9490 2438227 checkspecial2(&lsave);
9491 2438227 }
9492
9493
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2438505 times.
2438507 if(action==won)
9494 {
9495 2 return true;
9496 }
9497 2438505 }
9498
9499 // Somehow Hero was displaced from the fairy flag...
9500
3/6
✓ Branch 0 taken 9703 times.
✓ Branch 1 taken 2431941 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9703 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2441644 if(fairyclk && action != freeze && action != sideswimfreeze)
9501 {
9502 fairyclk = holdclk = refill_why = 0;
9503 }
9504
9505
2/4
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441644 times.
✗ Branch 3 not taken.
2441644 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9506 {
9507 tmpscr->timedwarptics--;
9508
9509 if(tmpscr->timedwarptics==0)
9510 {
9511 activated_timed_warp=true;
9512
9513 if(tmpscr->flags4 & fTIMEDDIRECT)
9514 {
9515 didpit=true;
9516 pitx=x;
9517 pity=y;
9518 }
9519
9520 int32_t index2 = 0;
9521
9522 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9523
9524 sdir = dir;
9525 dowarp(1,index2);
9526 }
9527 }
9528
9529 2441644 bool awarp = false;
9530 //!DIMI: Global Combo Effects (AUTO STUFF)
9531
2/2
✓ Branch 0 taken 97196 times.
✓ Branch 1 taken 2441644 times.
2538840 for(auto& p : slopes)
9532 {
9533 97196 slope_object& s = p.second;
9534 97196 s.updateslope(); //sets old x/y poses
9535 }
9536
2/2
✓ Branch 0 taken 2441644 times.
✓ Branch 1 taken 429729344 times.
432170988 for(int32_t i=0; i<176; ++i)
9537 {
9538
2/2
✓ Branch 0 taken 1569744 times.
✓ Branch 1 taken 1723626608 times.
1725196352 for(int32_t layer=0; layer<7; ++layer)
9539 {
9540
2/2
✓ Branch 0 taken 1293897264 times.
✓ Branch 1 taken 429729344 times.
1723626608 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9541 1723626608 newcombo const& cmb = combobuf[cid];
9542
9543
2/2
✓ Branch 0 taken 10988208 times.
✓ Branch 1 taken 1712638400 times.
1723626608 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9544 {
9545
2/2
✓ Branch 0 taken 428159600 times.
✓ Branch 1 taken 1284478800 times.
1712638400 if(layer > 2) break;
9546
4/4
✓ Branch 0 taken 428159600 times.
✓ Branch 1 taken 856319200 times.
✓ Branch 2 taken 428050656 times.
✓ Branch 3 taken 108944 times.
1284478800 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9547
4/4
✓ Branch 0 taken 428159600 times.
✓ Branch 1 taken 428268544 times.
✓ Branch 2 taken 108944 times.
✓ Branch 3 taken 428050656 times.
856428144 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9548 428377488 }
9549 439365696 int32_t ind=0;
9550
9551 //AUTOMATIC TRIGGER CODE
9552
1/2
✓ Branch 0 taken 439365696 times.
✗ Branch 1 not taken.
439365696 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9553 {
9554 do_trigger_combo(layer, i);
9555 }
9556
9557 //AUTO WARP CODE
9558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439365696 times.
439365696 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9559 {
9560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439365696 times.
439365696 if(cmb.type==cAWARPA)
9561 {
9562 awarp=true;
9563 ind=0;
9564 }
9565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439365696 times.
439365696 else if(cmb.type==cAWARPB)
9566 {
9567 awarp=true;
9568 ind=1;
9569 }
9570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439365696 times.
439365696 else if(cmb.type==cAWARPC)
9571 {
9572 awarp=true;
9573 ind=2;
9574 }
9575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439365696 times.
439365696 else if(cmb.type==cAWARPD)
9576 {
9577 awarp=true;
9578 ind=3;
9579 }
9580
1/2
✓ Branch 0 taken 439365696 times.
✗ Branch 1 not taken.
439365696 else if(cmb.type==cAWARPR)
9581 {
9582 awarp=true;
9583 ind=zc_oldrand()%4;
9584 }
9585 439365696 }
9586
1/2
✓ Branch 0 taken 439365696 times.
✗ Branch 1 not taken.
439365696 if(awarp)
9587 {
9588 if(tmpscr->flags5&fDIRECTAWARP)
9589 {
9590 didpit=true;
9591 pitx=x;
9592 pity=y;
9593 }
9594
9595 sdir = dir;
9596 dowarp(1,ind);
9597 break;
9598 }
9599 439365696 }
9600
1/2
✓ Branch 0 taken 429729344 times.
✗ Branch 1 not taken.
429729344 if(awarp) break;
9601 429729344 }
9602
9603 2441644 awarp=false;
9604
9605 2441644 word c = tmpscr->numFFC();
9606
2/2
✓ Branch 0 taken 2441644 times.
✓ Branch 1 taken 77977748 times.
80419392 for(word i=0; i<c; i++)
9607 {
9608 77977748 int32_t ind=0;
9609
9610 77977748 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9611
9612
1/2
✓ Branch 0 taken 77977748 times.
✗ Branch 1 not taken.
77977748 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9613 {
9614 do_trigger_combo_ffc(i);
9615 }
9616
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77977748 times.
77977748 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9618 {
9619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77977748 times.
77977748 if(cmb.type==cAWARPA)
9620 {
9621 awarp=true;
9622 ind=0;
9623 }
9624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77977748 times.
77977748 else if(cmb.type==cAWARPB)
9625 {
9626 awarp=true;
9627 ind=1;
9628 }
9629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77977748 times.
77977748 else if(cmb.type==cAWARPC)
9630 {
9631 awarp=true;
9632 ind=2;
9633 }
9634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77977748 times.
77977748 else if(cmb.type==cAWARPD)
9635 {
9636 awarp=true;
9637 ind=3;
9638 }
9639
1/2
✓ Branch 0 taken 77977748 times.
✗ Branch 1 not taken.
77977748 else if(cmb.type==cAWARPR)
9640 {
9641 awarp=true;
9642 ind=zc_oldrand()%4;
9643 }
9644 77977748 }
9645
9646
1/2
✓ Branch 0 taken 77977748 times.
✗ Branch 1 not taken.
77977748 if(awarp)
9647 {
9648 if(tmpscr->flags5&fDIRECTAWARP)
9649 {
9650 didpit=true;
9651 pitx=x;
9652 pity=y;
9653 }
9654
9655 sdir = dir;
9656 dowarp(1,ind);
9657 break;
9658 }
9659 77977748 }
9660 2441644 zfix dx, dy;
9661
7/8
✓ Branch 0 taken 6083 times.
✓ Branch 1 taken 2435561 times.
✓ Branch 2 taken 3100 times.
✓ Branch 3 taken 2983 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 1970 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1130 times.
2441644 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9662 {
9663
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1103 times.
1130 if (slide_slope(this, dx, dy, slopeid))
9664 {
9665 1103 onplatid = 5;
9666
3/4
✓ Branch 0 taken 809 times.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 809 times.
1103 if (dx || dy) push_move(dx, dy);
9667 1103 }
9668 1130 }
9669
2/2
✓ Branch 0 taken 2440021 times.
✓ Branch 1 taken 1623 times.
2441644 if (onplatid <= 0) slopeid = 0;
9670 1623 else --onplatid;
9671
2/2
✓ Branch 0 taken 1948702 times.
✓ Branch 1 taken 492942 times.
2441644 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9672
5/6
✓ Branch 0 taken 903 times.
✓ Branch 1 taken 2441623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 903 times.
✓ Branch 4 taken 882 times.
✓ Branch 5 taken 2441644 times.
2442526 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9673 {
9674
2/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 882 times.
882 if (check_slope(this, true) && !toogam)
9675 {
9676 882 slope_info const& s = get_slope(this, true).get_info();
9677 882 bool staircheck = false;
9678
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 18 times.
882 if (s.slope() != slopeid && slopeid) staircheck = true;
9679
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 30 times.
882 if (onplatform) staircheck = true;
9680 882 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9681
9682
4/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 36 times.
882 if (dx || dy)
9683 {
9684 846 int32_t pushret = push_move(dx,dy);
9685
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 13 times.
846 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9686
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 2 times.
846 if (s.slope() != slopeid && slopeid) staircheck = true;
9687
2/2
✓ Branch 0 taken 835 times.
✓ Branch 1 taken 11 times.
846 if (onplatform) staircheck = true;
9688
4/4
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 822 times.
846 if(sideview_mode() && slopeid)
9689 822 onplatid = 5;
9690
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if (pushret == 1)
9691 {
9692 dx = -1;
9693 dy = 0;
9694 slope_push_int(s, this, dx, dy, staircheck);
9695 push_move(dx,dy);
9696 }
9697
2/2
✓ Branch 0 taken 839 times.
✓ Branch 1 taken 7 times.
846 if (pushret == 2)
9698 {
9699 7 dx = 0;
9700 7 dy = -1;
9701 7 slope_push_int(s, this, dx, dy, staircheck);
9702 7 push_move(dx,dy);
9703 7 }
9704 846 }
9705 882 }
9706 882 }
9707
9708
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 if(ffwarp)
9709 {
9710 if(ffpit)
9711 {
9712 ffpit=false;
9713 didpit=true;
9714 pitx=x;
9715 pity=y;
9716 }
9717
9718 ffwarp=false;
9719 dowarp(1,0);
9720 }
9721
9722 //Hero->WarpEx
9723
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 if ( FFCore.warpex[wexActive] )
9724 {
9725 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9726 FFCore.warpex[wexActive] = 0;
9727 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9728 for ( int32_t q = 0; q < wexActive; q++ )
9729 {
9730 temp_warpex[q] = FFCore.warpex[q];
9731 FFCore.warpex[q] = 0;
9732 }
9733 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9734 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9735 }
9736
9737 // walk through bombed doors and fake walls
9738 2441644 bool walk=false;
9739 2441644 int32_t dtype=dBOMBED;
9740
9741
2/2
✓ Branch 0 taken 2431774 times.
✓ Branch 1 taken 9870 times.
2441644 if(pushing>=24) dtype=dWALK;
9742
9743
14/18
✓ Branch 0 taken 1817413 times.
✓ Branch 1 taken 624231 times.
✓ Branch 2 taken 1800589 times.
✓ Branch 3 taken 16824 times.
✓ Branch 4 taken 1800589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1798166 times.
✓ Branch 7 taken 2423 times.
✓ Branch 8 taken 1796360 times.
✓ Branch 9 taken 1806 times.
✓ Branch 10 taken 1796360 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1789401 times.
✓ Branch 13 taken 6959 times.
✓ Branch 14 taken 1789401 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1789401 times.
2441644 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9744 {
9745
12/16
✓ Branch 0 taken 8103 times.
✓ Branch 1 taken 1781298 times.
✓ Branch 2 taken 292648 times.
✓ Branch 3 taken 1488650 times.
✓ Branch 4 taken 292648 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 292648 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 58511 times.
✓ Branch 11 taken 234137 times.
✓ Branch 12 taken 16709 times.
✓ Branch 13 taken 41802 times.
✓ Branch 14 taken 16646 times.
✓ Branch 15 taken 63 times.
1789401 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9746 {
9747 63 walk=true;
9748 63 dir=up;
9749 63 }
9750
9751
12/16
✓ Branch 0 taken 8103 times.
✓ Branch 1 taken 1781298 times.
✓ Branch 2 taken 232464 times.
✓ Branch 3 taken 1548834 times.
✓ Branch 4 taken 240567 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 240567 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 30384 times.
✓ Branch 11 taken 210183 times.
✓ Branch 12 taken 8259 times.
✓ Branch 13 taken 22125 times.
✓ Branch 14 taken 8205 times.
✓ Branch 15 taken 54 times.
1789401 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9752 {
9753 54 walk=true;
9754 54 dir=down;
9755 54 }
9756
9757
10/14
✓ Branch 0 taken 8103 times.
✓ Branch 1 taken 1781298 times.
✓ Branch 2 taken 9963 times.
✓ Branch 3 taken 1771335 times.
✓ Branch 4 taken 18066 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18066 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 10376 times.
✓ Branch 11 taken 7690 times.
✓ Branch 12 taken 10332 times.
✓ Branch 13 taken 44 times.
1789401 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9758 {
9759 44 walk=true;
9760 44 dir=left;
9761 44 }
9762
9763
10/14
✓ Branch 0 taken 1781298 times.
✓ Branch 1 taken 8103 times.
✓ Branch 2 taken 14932 times.
✓ Branch 3 taken 1766366 times.
✓ Branch 4 taken 23035 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23035 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 14352 times.
✓ Branch 11 taken 8683 times.
✓ Branch 12 taken 14295 times.
✓ Branch 13 taken 57 times.
1789401 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9764 {
9765 57 walk=true;
9766 57 dir=right;
9767 57 }
9768 1789401 }
9769
9770
2/2
✓ Branch 0 taken 2441426 times.
✓ Branch 1 taken 218 times.
2441644 if(walk)
9771 {
9772 218 hclk=0;
9773 218 drawguys=false;
9774
9775
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 65 times.
218 if(dtype==dWALK)
9776 {
9777 65 sfx(tmpscr->secretsfx);
9778 65 }
9779
9780 218 action=none; FFCore.setHeroAction(none);
9781 218 stepforward(29, true);
9782 218 action=scrolling; FFCore.setHeroAction(scrolling);
9783 218 pushing=false;
9784 218 }
9785
9786
4/6
✓ Branch 0 taken 26206 times.
✓ Branch 1 taken 2415438 times.
✓ Branch 2 taken 26206 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26206 times.
2441644 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9787 {
9788
1/2
✓ Branch 0 taken 26206 times.
✗ Branch 1 not taken.
26206 if(heart_beep)
9789 {
9790 26206 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9791 26206 }
9792 else
9793 {
9794 if ( heart_beep_timer == -1 )
9795 {
9796 heart_beep_timer = 70;
9797 }
9798
9799 if ( heart_beep_timer > 0 )
9800 {
9801 --heart_beep_timer;
9802 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9803 }
9804 else
9805 {
9806 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9807 }
9808 }
9809 26206 }
9810 else
9811 {
9812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2415438 times.
2415438 if ( heart_beep_timer > -2 )
9813 {
9814 2415438 heart_beep_timer = -1;
9815 2415438 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9816 2415438 }
9817 }
9818
9819
2/2
✓ Branch 0 taken 2441366 times.
✓ Branch 1 taken 278 times.
2441644 if(rSbtn())
9820 {
9821 278 int32_t tmp_subscr_clk = frame;
9822
9823 278 int32_t save_type = 0;
9824
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 278 times.
✗ Branch 3 not taken.
278 switch(lsave)
9825 {
9826 case 0:
9827 {
9828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if( FFCore.runActiveSubscreenScriptEngine() )
9829 {
9830 break;
9831 }
9832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 else if ( !stopSubscreenFalling() )
9833 {
9834 278 conveyclk=3;
9835 278 dosubscr(&QMisc);
9836 278 newscr_clk += frame - tmp_subscr_clk;
9837 278 }
9838 278 break;
9839 }
9840
9841
9842 case 2:
9843 save_type = 1;
9844 [[fallthrough]];
9845 case 1:
9846 if(last_savepoint_id)
9847 trigger_save(combobuf[last_savepoint_id]);
9848 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9849 break;
9850 }
9851 278 }
9852
9853
2/2
✓ Branch 0 taken 180391 times.
✓ Branch 1 taken 2261253 times.
2441644 if (!checkstab() )
9854 {
9855 /*
9856 for(int32_t q=0; q<176; q++)
9857 {
9858 set_bit(screengrid,q,0);
9859 }
9860
9861 for(int32_t q=0; q<MAXFFCS; q++)
9862 set_bit(ffcgrid, q, 0);
9863 */
9864 2261253 }
9865
9866 2441644 check_conveyor();
9867 2441644 PhantomsCleanup();
9868 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9869
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 if(attack==wHammer)
9870 {
9871 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9872 {
9873 switch(dir) //Hero's dir
9874 {
9875 case up:
9876 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9877 break;
9878
9879 case down:
9880 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9881 break;
9882
9883 case left:
9884 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9885 break;
9886
9887 case right:
9888 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9889 break;
9890 }
9891
9892 }
9893 }
9894
9895 2441644 handleSpotlights();
9896
9897
2/2
✓ Branch 0 taken 2441334 times.
✓ Branch 1 taken 310 times.
2441644 if(getOnSideviewLadder())
9898 {
9899
5/8
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 304 times.
310 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9900 {
9901 6 setOnSideviewLadder(false);
9902 6 }
9903
6/8
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 175 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
304 else if(CANFORCEFACEUP)
9904 {
9905 181 setDir(up);
9906 181 }
9907 310 }
9908
9909 2441644 return false;
9910 2441884 }
9911
9912 3307 bool HeroClass::push_pixel(zfix dx, zfix dy)
9913 {
9914
2/4
✓ Branch 0 taken 3307 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3307 times.
✗ Branch 3 not taken.
3307 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9915
3/4
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 2020 times.
✓ Branch 2 taken 1287 times.
✗ Branch 3 not taken.
3307 if(dx && dy)
9916 {
9917 bool r = push_pixel(0,dy);
9918 bool r2 = push_pixel(dx,0);
9919 return r && r2;
9920 }
9921
2/2
✓ Branch 0 taken 1170 times.
✓ Branch 1 taken 2137 times.
3307 if(dx < 0)
9922 {
9923
1/2
✓ Branch 0 taken 1170 times.
✗ Branch 1 not taken.
2340 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9924
1/2
✓ Branch 0 taken 1170 times.
✗ Branch 1 not taken.
1170 || solpush_walkflag(x+dx,y+8,1,this)
9925
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1170 times.
✓ Branch 2 taken 953 times.
✓ Branch 3 taken 217 times.
1170 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9926 {
9927 1170 x += dx;
9928 1170 return true;
9929 }
9930 return false;
9931 }
9932
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 2020 times.
2137 else if(dx > 0)
9933 {
9934
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
234 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9935
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 || solpush_walkflag(x+15+dx,y+8,1,this)
9936
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 56 times.
117 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9937 {
9938 117 x += dx;
9939 117 return true;
9940 }
9941 return false;
9942 }
9943
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 393 times.
2020 else if(dy < 0)
9944 {
9945
2/2
✓ Branch 0 taken 1615 times.
✓ Branch 1 taken 12 times.
3242 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9946
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1615 times.
✓ Branch 2 taken 1501 times.
✓ Branch 3 taken 114 times.
1627 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9947 {
9948 1615 y += dy;
9949 1615 return true;
9950 }
9951 12 return false;
9952 }
9953
1/2
✓ Branch 0 taken 393 times.
✗ Branch 1 not taken.
393 else if(dy > 0)
9954 {
9955
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 36 times.
761 if(!(solpush_walkflag(x,y+15+dy,2,this)
9956
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 288 times.
393 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
9957 {
9958 357 y += dy;
9959 357 return true;
9960 }
9961 36 return false;
9962 }
9963 return false;
9964 3307 }
9965 1632 int32_t HeroClass::push_move(zfix dx, zfix dy)
9966 {
9967 1632 int32_t ret = 0;
9968
4/4
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 2927 times.
✓ Branch 2 taken 1632 times.
✓ Branch 3 taken 2582 times.
4214 while(dx || dy)
9969 {
9970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2582 times.
2582 if(check_pitslide() != -1)
9971 break;
9972
2/2
✓ Branch 0 taken 562 times.
✓ Branch 1 taken 2020 times.
2582 if(dy)
9973 {
9974
2/2
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 17 times.
2020 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
9975 2020 dy -= cy;
9976
2/2
✓ Branch 0 taken 1972 times.
✓ Branch 1 taken 48 times.
2020 if(!push_pixel(0,cy))
9977 {
9978 48 dy = 0;
9979 48 ret |= 2;
9980 48 }
9981 2020 }
9982
2/2
✓ Branch 0 taken 1295 times.
✓ Branch 1 taken 1287 times.
2582 if(dx)
9983 {
9984
2/2
✓ Branch 0 taken 626 times.
✓ Branch 1 taken 661 times.
1287 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
9985 1287 dx -= cx;
9986
1/2
✓ Branch 0 taken 1287 times.
✗ Branch 1 not taken.
1287 if(!push_pixel(cx,0))
9987 {
9988 dx = 0;
9989 ret |= 1;
9990 }
9991 1287 }
9992 }
9993 1632 return ret;
9994 }
9995
9996 2441874 bool HeroClass::setSolid(bool set)
9997 {
9998
1/2
✓ Branch 0 taken 2441874 times.
✗ Branch 1 not taken.
2441874 bool actual = set && !toogam; //not solid when noclipping
9999 2441874 bool ret = solid_object::setSolid(actual);
10000 2441874 solid = set;
10001 2441874 return ret;
10002 }
10003
10004 3851 void HeroClass::solid_push(solid_object* obj)
10005 {
10006
1/2
✓ Branch 0 taken 3851 times.
✗ Branch 1 not taken.
3851 if(obj == this) return; //can't push self
10007
10008 3851 zfix dx, dy;
10009 3851 int32_t hdir = -1;
10010 3851 solid_push_int(obj,dx,dy,hdir);
10011
10012
4/4
✓ Branch 0 taken 3557 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 3366 times.
✓ Branch 3 taken 191 times.
3851 if(!dx && !dy) return;
10013
10014 485 obj->doContactDamage(hdir);
10015
10016 485 bool t = obj->getTempNonsolid();
10017 485 obj->setTempNonsolid(true);
10018
10019 485 push_move(dx,dy);
10020
10021 485 obj->setTempNonsolid(t);
10022 3851 }
10023
10024 // A routine used exclusively by startwpn,
10025 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10026 414 void HeroClass::deselectbombs(int32_t super)
10027 {
10028
5/10
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 414 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 414 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 414 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 414 times.
414 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10029
2/6
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 414 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
414 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10030 {
10031
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 414 times.
414 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10032 414 Bwpn = Bweapon(temp);
10033 414 directItemB = directItem;
10034 414 game->bwpn = temp;
10035 414 }
10036
10037 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10038 {
10039 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10040 Xwpn = Bweapon(temp);
10041 directItemX = directItem;
10042 game->xwpn = temp;
10043 }
10044 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10045 {
10046 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10047 Ywpn = Bweapon(temp);
10048 directItemY = directItem;
10049 game->ywpn = temp;
10050 }
10051 else
10052 {
10053 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10054 Awpn = Bweapon(temp);
10055 directItemA = directItem;
10056 game->awpn = temp;
10057 }
10058 414 }
10059
10060 int32_t potion_life=0;
10061 int32_t potion_magic=0;
10062
10063 bool HeroClass::mirrorBonk()
10064 {
10065 zfix tx = x, ty = y, tz = z;
10066 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10067 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10068 execute(info);
10069 bool fail = info.isUnwalkable();
10070
10071 if(!fail) //not solid, but check for water/pits...
10072 {
10073 //{ Check water collision.... GAAAAAAAH THIS IS A MESS
10074 int32_t water = 0;
10075 int32_t types[4] = {0};
10076 int32_t x1 = x+4, x2 = x+11,
10077 y1 = y+9, y2 = y+15;
10078 if (get_bit(quest_rules, qr_SMARTER_WATER))
10079 {
10080 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10081 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10082 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10083 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10084 }
10085 else
10086 {
10087 types[0] = COMBOTYPE(x1,y1);
10088
10089 if(MAPFFCOMBO(x1,y1))
10090 types[0] = FFCOMBOTYPE(x1,y1);
10091
10092 types[1] = COMBOTYPE(x1,y2);
10093
10094 if(MAPFFCOMBO(x1,y2))
10095 types[1] = FFCOMBOTYPE(x1,y2);
10096
10097 types[2] = COMBOTYPE(x2,y1);
10098
10099 if(MAPFFCOMBO(x2,y1))
10100 types[2] = FFCOMBOTYPE(x2,y1);
10101
10102 types[3] = COMBOTYPE(x2,y2);
10103
10104 if(MAPFFCOMBO(x2,y2))
10105 types[3] = FFCOMBOTYPE(x2,y2);
10106
10107 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10108 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10109 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10110
10111 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10112 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10113 water = typec;
10114 }
10115 if(water > 0)
10116 {
10117 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10118 {
10119 fail = true;
10120 }
10121 }
10122 //}
10123 if(pitslide() || fallclk)
10124 fail = true;
10125 fallclk = 0;
10126 }
10127 x = tx; y = ty; z = tz;
10128 return fail;
10129 }
10130
10131 void HeroClass::doMirror(int32_t mirrorid)
10132 {
10133 if(z > 0 || fakez > 0) return; //No mirror in air
10134 if(mirrorid < 0)
10135 mirrorid = current_item_id(itype_mirror);
10136 if(mirrorid < 0) return;
10137
10138 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10139 {
10140 if(QMisc.miscsfx[sfxERROR])
10141 sfx(QMisc.miscsfx[sfxERROR]);
10142 return;
10143 }
10144 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10145 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10146 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10147 for(auto pos : posarr)
10148 {
10149 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10150 {
10151 if(QMisc.miscsfx[sfxERROR])
10152 sfx(QMisc.miscsfx[sfxERROR]);
10153 return;
10154 }
10155 }
10156
10157 itemdata const& mirror = itemsbuf[mirrorid];
10158 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10159 {
10160 paymagiccost(mirrorid);
10161 if(mirror.usesound2) sfx(mirror.usesound2);
10162
10163 doWarpEffect(mirror.misc2, true);
10164 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10165 {
10166 Quit = qCONT;
10167 skipcont = 1;
10168 }
10169 else //Act as Farore's Wind
10170 {
10171 int32_t nayrutemp=nayruitem;
10172 restart_level();
10173 nayruitem=nayrutemp;
10174 magicitem=-1;
10175 magiccastclk=0;
10176 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10177 }
10178 }
10179 else
10180 {
10181 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10182 int32_t offscr = currscr - DMaps[currdmap].xoff;
10183 if(destdmap < 0)
10184 return;
10185 int32_t destscr = DMaps[destdmap].xoff + offscr;
10186 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10187 return;
10188 paymagiccost(mirrorid);
10189
10190 //Store some values to restore if 'warp fails'
10191 int32_t tLastEntrance = lastentrance,
10192 tLastEntranceDMap = lastentrance_dmap,
10193 tContScr = game->get_continue_scrn(),
10194 tContDMap = game->get_continue_dmap(),
10195 tPortalDMap = game->portalsrcdmap;
10196 int32_t sourcescr = currscr, sourcedmap = currdmap;
10197 zfix tx = x, ty = y, tz = z;
10198 game->portalsrcdmap = -1;
10199 action = none; FFCore.setHeroAction(none);
10200
10201 //Warp to new dmap
10202 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10203 mirror.usesound, 0, -1);
10204
10205 //Check for valid landing location
10206 if(mirrorBonk()) //Invalid landing, warp back!
10207 {
10208 action = none; FFCore.setHeroAction(none);
10209 lastentrance = tLastEntrance;
10210 lastentrance_dmap = tLastEntranceDMap;
10211 game->set_continue_scrn(tContScr);
10212 game->set_continue_dmap(tContDMap);
10213 x = tx;
10214 y = ty;
10215 z = tz;
10216 game->portalsrcdmap = tPortalDMap;
10217 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10218 mirror.usesound, 0, -1);
10219 }
10220 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10221 {
10222 //Place the portal
10223 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10224 //Since it was placed after loading this screen, load the portal object now
10225 game->load_portal();
10226 //Don't immediately trigger the warp back
10227 can_mirror_portal = false;
10228
10229 //Set continue point
10230 if(currdmap != game->get_continue_dmap())
10231 {
10232 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10233 }
10234 game->set_continue_dmap(currdmap);
10235 lastentrance_dmap = currdmap;
10236 lastentrance = game->get_continue_scrn();
10237 }
10238 }
10239 }
10240
10241 2441646 void HeroClass::handle_passive_buttons()
10242 {
10243 2441646 do_liftglove(-1,true);
10244 2441646 do_jump(-1,true);
10245 2441646 }
10246
10247 static bool did_passive_jump = false;
10248 2441687 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10249 {
10250
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 2441646 times.
2441687 if(passive) did_passive_jump = false;
10251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 else if(did_passive_jump) return false; //don't jump twice in the same frame
10252
10253
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 2441646 times.
2441687 if(jumpid < 0)
10254 2441646 jumpid = current_item_id(itype_rocs,true,true);
10255
10256
2/2
✓ Branch 0 taken 2432727 times.
✓ Branch 1 taken 8960 times.
2441687 if(unsigned(jumpid) >= MAXITEMS) return false;
10257
2/4
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8960 times.
8960 if(inlikelike || charging) return false;
10258
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!checkitem_jinx(jumpid)) return false;
10259
10260 8960 itemdata const& itm = itemsbuf[jumpid];
10261
10262 8960 bool standing = isStanding(true);
10263
3/4
✓ Branch 0 taken 7476 times.
✓ Branch 1 taken 1484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1484 times.
8960 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10264
4/6
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1484 times.
✓ Branch 3 taken 7476 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1484 times.
8960 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10265
2/4
✓ Branch 0 taken 7476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7476 times.
7476 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10266 {
10267 if(QMisc.miscsfx[sfxERROR])
10268 sfx(QMisc.miscsfx[sfxERROR]);
10269 return false;
10270 }
10271
10272 7476 byte intbtn = byte(itm.misc2&0xFF);
10273
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 7437 times.
7476 if(passive)
10274 {
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7437 times.
7437 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10276 7437 return false; //not pressed
10277 }
10278
10279 39 paymagiccost(jumpid);
10280
10281
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(!standing)
10282 {
10283 ++extra_jump_count;
10284 fall = 0;
10285 fakefall = 0;
10286 if(hoverclk > 0)
10287 hoverclk = -hoverclk;
10288 }
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(itm.flags & ITEM_FLAG1)
10290 setFall(fall - itm.power);
10291 39 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10292 39 coyotetime = 65535; //jumped, so no coyotetime
10293 39 setOnSideviewLadder(false);
10294
10295 // Reset the ladder, unless on an unwalkable combo
10296
3/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
39 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10297 reset_ladder();
10298
10299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(itm.usesound)
10300 39 sfx(itm.usesound,pan(x.getInt()));
10301
10302
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(passive) did_passive_jump = true;
10303 39 return true;
10304 2441687 }
10305 195 void HeroClass::drop_liftwpn()
10306 {
10307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 if(!lift_wpn) return;
10308
10309 handle_lift(false); //sets position properly, accounting for large weapons
10310 auto liftid = current_item_id(itype_liftglove,true,true);
10311 itemdata const& glove = itemsbuf[liftid];
10312 if(glove.flags & ITEM_FLAG1)
10313 {
10314 lift_wpn->z = 0;
10315 lift_wpn->fakez = liftheight;
10316 }
10317 else lift_wpn->z = liftheight;
10318 lift_wpn->dir = dir;
10319 lift_wpn->step = 0;
10320 lift_wpn->fakefall = 0;
10321 lift_wpn->fall = 0;
10322 if(glove.flags & ITEM_FLAG1)
10323 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10324 else
10325 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10326 Lwpns.add(lift_wpn);
10327 lift_wpn = nullptr;
10328 195 }
10329 2441646 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10330 {
10331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441646 times.
2441646 if(liftid < 0)
10332 2441646 liftid = current_item_id(itype_liftglove,true,true);
10333
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 2441027 times.
2441646 if(!can_lift(liftid)) return;
10334 619 itemdata const& glove = itemsbuf[liftid];
10335 619 byte intbtn = byte(glove.misc1&0xFF);
10336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(passive)
10337 {
10338
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 610 times.
619 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10339 610 return; //not pressed
10340 9 }
10341
10342 9 bool had_weapon = lift_wpn;
10343
10344
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10345
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (checkbunny(liftid) && checkmagiccost(liftid))))
10346 {
10347 if(QMisc.miscsfx[sfxERROR])
10348 sfx(QMisc.miscsfx[sfxERROR]);
10349 return;
10350 }
10351
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10352 return;
10353
10354 9 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10355
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(glove.script)
10356 {
10357 if(!paidmagic)
10358 {
10359 paidmagic = true;
10360 paymagiccost(liftid);
10361 }
10362
10363 ri = &(itemScriptData[liftid]);
10364 for ( int32_t q = 0; q < 1024; q++ )
10365 item_stack[liftid][q] = 0xFFFF;
10366 ri->Clear();
10367 item_doscript[liftid] = 1;
10368 itemscriptInitialised[liftid] = 0;
10369 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10370
10371 bool has_weapon = lift_wpn;
10372 if(has_weapon != had_weapon) //Item action script changed the lift information
10373 {
10374 if(passive)
10375 {
10376 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10377 }
10378 return;
10379 }
10380 }
10381
10382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(lift_wpn)
10383 {
10384 if(!paidmagic)
10385 {
10386 paidmagic = true;
10387 paymagiccost(liftid);
10388 }
10389 if(!liftclk)
10390 {
10391 //Throw the weapon!
10392 //hero's direction and position
10393 handle_lift(false); //sets position properly, accounting for large weapons
10394 if(glove.flags & ITEM_FLAG1)
10395 {
10396 lift_wpn->z = 0;
10397 lift_wpn->fakez = liftheight;
10398 }
10399 else lift_wpn->z = liftheight;
10400 lift_wpn->dir = dir;
10401 //Configured throw speed in both axes
10402 lift_wpn->step = zfix(glove.misc2)/100;
10403 if(glove.flags & ITEM_FLAG1)
10404 {
10405 lift_wpn->fakefall = -glove.misc3;
10406 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10407 }
10408 else
10409 {
10410 lift_wpn->fall = -glove.misc3;
10411 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10412 }
10413 Lwpns.add(lift_wpn);
10414 lift_wpn = nullptr;
10415 if(glove.usesound2)
10416 sfx(glove.usesound2,pan(int32_t(x)));
10417 }
10418
10419 if(passive)
10420 {
10421 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10422 }
10423 return;
10424 }
10425
10426 //Check for a liftable combo
10427 9 zfix bx, by;
10428 9 zfix bx2, by2;
10429
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
9 switch(dir)
10430 {
10431 case up:
10432 9 by = y + (bigHitbox ? -2 : 6);
10433 9 by2 = by;
10434 9 bx = x + 4;
10435 9 bx2 = bx + 8;
10436 9 break;
10437 case down:
10438 by = y + 17;
10439 by2 = by;
10440 bx = x + 4;
10441 bx2 = bx + 8;
10442 break;
10443 case left:
10444 by = y + (bigHitbox ? 0 : 8);
10445 by2 = y + 8;
10446 bx = x - 2;
10447 bx2 = x - 2;
10448 break;
10449 case right:
10450 by = y + (bigHitbox ? 0 : 8);
10451 by2 = y + 8;
10452 bx = x + 17;
10453 bx2 = x + 17;
10454 break;
10455 }
10456 9 int32_t pos = COMBOPOS_B(bx,by);
10457 9 int32_t pos2 = COMBOPOS_B(bx2,by2);
10458 9 int32_t foundpos = -1;
10459
10460 9 bool lifted = false;
10461
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
72 for(auto lyr = 6; lyr >= 0; --lyr)
10462 {
10463 63 mapscr* scr = FFCore.tempScreens[lyr];
10464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(pos > -1)
10465 {
10466 63 newcombo const& cmb = combobuf[scr->data[pos]];
10467
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb.liftflags & LF_LIFTABLE)
10468 {
10469 if(do_lift_combo(lyr,pos,liftid))
10470 {
10471 lifted = true;
10472 break;
10473 }
10474 }
10475 63 }
10476
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(pos != pos2 && pos2 > -1)
10477 {
10478 63 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10479
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb2.liftflags & LF_LIFTABLE)
10480 {
10481 if(do_lift_combo(lyr,pos2,liftid))
10482 {
10483 lifted = true;
10484 break;
10485 }
10486 }
10487 63 }
10488 63 }
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!lifted) return;
10490 if(!paidmagic)
10491 {
10492 paidmagic = true;
10493 paymagiccost(liftid);
10494 }
10495 if(passive)
10496 {
10497 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10498 }
10499 return;
10500 2441646 }
10501 void HeroClass::handle_lift(bool dec)
10502 {
10503 lift_wpn->fakez = 0;
10504 if(!lift_wpn) liftclk = 0;
10505 if(liftclk <= (dec?1:0))
10506 {
10507 liftclk = 0;
10508 tliftclk = 0;
10509 if(lift_wpn)
10510 {
10511 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10512 {
10513 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10514 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10515 }
10516 else
10517 {
10518 lift_wpn->x = x;
10519 lift_wpn->y = y;
10520 }
10521 lift_wpn->z = liftheight;
10522 }
10523 if(action == lifting)
10524 {
10525 action = none; FFCore.setHeroAction(none);
10526 }
10527 return;
10528 }
10529 if(dec) --liftclk;
10530 double xdist, ydist;
10531 double perc = (liftclk/double(tliftclk));
10532 switch(dir)
10533 {
10534 case up:
10535 {
10536 xdist = 0;
10537 ydist = -16;
10538 if(lift_wpn->txsz > 1)
10539 {
10540 xdist = -((lift_wpn->txsz*8)-8);
10541 }
10542 else xdist = 0;
10543 if(lift_wpn->tysz > 1)
10544 {
10545 ydist = -(lift_wpn->tysz*16);
10546 }
10547 ydist *= perc;
10548 break;
10549 }
10550 case down:
10551 {
10552 xdist = 0;
10553 ydist = 16;
10554 if(lift_wpn->txsz > 1)
10555 {
10556 xdist = -((lift_wpn->txsz*8)-8);
10557 }
10558 else xdist = 0;
10559 ydist *= perc;
10560 break;
10561 }
10562 case left:
10563 {
10564 xdist = -16;
10565 ydist = 0;
10566 if(lift_wpn->txsz > 1)
10567 {
10568 xdist = -(lift_wpn->txsz*16);
10569 }
10570 if(lift_wpn->tysz > 1)
10571 {
10572 ydist = -((lift_wpn->tysz*8)-8);
10573 }
10574 else ydist = 0;
10575 xdist *= perc;
10576 break;
10577 }
10578 case right:
10579 {
10580 xdist = 16;
10581 ydist = 0;
10582 if(lift_wpn->tysz > 1)
10583 {
10584 ydist = -((lift_wpn->tysz*8)-8);
10585 }
10586 else ydist = 0;
10587 xdist *= perc;
10588 break;
10589 }
10590 }
10591
10592 lift_wpn->x = x + xdist;
10593 lift_wpn->y = y + ydist;
10594 lift_wpn->z = liftheight*(1.0-perc);
10595 }
10596 2441646 bool HeroClass::can_lift(int32_t gloveid)
10597 {
10598
2/2
✓ Branch 0 taken 2441027 times.
✓ Branch 1 taken 619 times.
2441646 if(unsigned(gloveid) >= MAXITEMS) return false;
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(lstunclock) return false;
10600
1/2
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
619 if(!checkitem_jinx(gloveid)) return false;
10601 619 itemdata const& glove = itemsbuf[gloveid];
10602
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
✗ Branch 2 not taken.
619 switch(action)
10603 {
10604 case none: case walking:
10605 619 break;
10606
10607 case swimming:
10608 if(glove.flags & ITEM_FLAG2)
10609 break;
10610 return false;
10611
10612 default:
10613 return false;
10614 }
10615 619 return true;
10616 2441646 }
10617 void HeroClass::lift(weapon* w, byte timer, zfix height)
10618 {
10619 lift_wpn = w;
10620 liftclk = timer;
10621 tliftclk = timer;
10622 if(height < 0)
10623 liftheight = 0;
10624 else liftheight = height;
10625 }
10626
10627 void HeroClass::doSwitchHook(byte style)
10628 {
10629 hs_switcher = true;
10630 pull_hero = true;
10631 //{ Load hook weapons, set them to obey special drawing
10632 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10633 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10634
10635 if(w)
10636 w->switch_hooked = true;
10637 if(hw)
10638 hw->switch_hooked = true;
10639 for(int32_t j=0; j<chainlinks.Count(); j++)
10640 {
10641 chainlinks.spr(j)->switch_hooked = true;
10642 }
10643 //}
10644 if(hooked_combopos > -1)
10645 {
10646 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10647 hooked_layerbits = 0;
10648 for(auto q = 0; q < 7; ++q)
10649 hooked_undercombos[q] = -1;
10650 uint16_t plpos = COMBOPOS(x+8,y+8);
10651 for(auto q = max_layer; q > -1; --q)
10652 {
10653 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10654 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10655 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10656 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10657 bool isPush = false;
10658 if(isSwitchHookable(cmb))
10659 {
10660 if(cmb.type == cSWITCHHOOK)
10661 {
10662 uint16_t plpos = COMBOPOS(x+8,y+8);
10663 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10664 continue; //don't swap with non-zero combo
10665 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10666 continue; //too low a switchhook level
10667 hooked_layerbits |= 1<<q; //Swapping
10668 if(cmb.usrflags&cflag3)
10669 {
10670 if(cmb.usrflags&cflag6)
10671 {
10672 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10673 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10674 }
10675 else
10676 {
10677 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10678 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10679 }
10680 }
10681 else
10682 {
10683 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10684 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10685 isPush = true;
10686 }
10687 }
10688 else if(isCuttableType(cmb.type))
10689 {
10690 if(isCuttableNextType(cmb.type))
10691 {
10692 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10693 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10694 }
10695 else
10696 {
10697 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10698 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10699 }
10700 hooked_layerbits |= 1<<q; //Swapping
10701 }
10702 else
10703 {
10704 hooked_layerbits |= 1<<q; //Swapping
10705 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10706 }
10707 }
10708 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10709 {
10710 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10711 && hasMainGuy())
10712 {
10713 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10714 continue;
10715 }
10716 if(fl1 == mfPUSHED)
10717 {
10718 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10719 continue;
10720 }
10721 if(!isPush) switch(fl1)
10722 {
10723 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10724 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10725 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10726 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10727 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10728 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10729 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10730 isPush = true;
10731 }
10732 if(!isPush) switch(cmb.flag)
10733 {
10734 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10735 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10736 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10737 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10738 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10739 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10740 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10741 isPush = true;
10742 }
10743 if(isPush) //Check for block holes / triggers
10744 {
10745 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10746 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10747 {
10748 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10749 }
10750 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10751 {
10752 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10753 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10754 {
10755 if(lyr == q) continue;
10756 switch(FFCore.tempScreens[q]->sflag[plpos])
10757 {
10758 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10759 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10760 lyr=7;
10761 break;
10762 }
10763 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10764 {
10765 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10766 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10767 lyr=7;
10768 break;
10769 }
10770 }
10771 }
10772 }
10773 }
10774 }
10775 }
10776 switch_hooked = true;
10777 switchhookstyle = style;
10778 switch(style)
10779 {
10780 default: case swPOOF:
10781 {
10782 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10783 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10784 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10785 if(hooked_combopos > -1)
10786 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10787 else if(switching_object)
10788 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10789 break;
10790 }
10791 case swFLICKER:
10792 {
10793 switchhookmaxtime = switchhookclk = 64;
10794 break;
10795 }
10796 case swRISE:
10797 {
10798 switchhookmaxtime = switchhookclk = 64;
10799 break;
10800 }
10801 }
10802 }
10803
10804 13561 bool HeroClass::startwpn(int32_t itemid)
10805 {
10806
1/2
✓ Branch 0 taken 13561 times.
✗ Branch 1 not taken.
13561 if(itemid < 0) return false;
10807 13561 itemdata const& itm = itemsbuf[itemid];
10808
5/6
✓ Branch 0 taken 3025 times.
✓ Branch 1 taken 10536 times.
✓ Branch 2 taken 2689 times.
✓ Branch 3 taken 7847 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
13573 if(((dir==up && y<24) || (dir==down && y>128) ||
10809
5/6
✓ Branch 0 taken 3989 times.
✓ Branch 1 taken 3858 times.
✓ Branch 2 taken 3858 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 13549 times.
13561 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10810 12 return false;
10811
10812 13549 int32_t wx=x;
10813 13549 int32_t wy=y-fakez;
10814 13549 int32_t wz=z;
10815 13549 bool ret = true;
10816
10817
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
✓ Branch 2 taken 2688 times.
✓ Branch 3 taken 3982 times.
✓ Branch 4 taken 3855 times.
13549 switch(dir)
10818 {
10819 case up:
10820 3024 wy-=16;
10821 3024 break;
10822
10823 case down:
10824 2688 wy+=16;
10825 2688 break;
10826
10827 case left:
10828 3982 wx-=16;
10829 3982 break;
10830
10831 case right:
10832 3855 wx+=16;
10833 3855 break;
10834 }
10835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13549 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10836
10837
14/27
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 41 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 102 times.
✓ Branch 11 taken 402 times.
✓ Branch 12 taken 12 times.
✓ Branch 13 taken 611 times.
✓ Branch 14 taken 7244 times.
✓ Branch 15 taken 554 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 226 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 4308 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
13549 switch(itm.family)
10838 {
10839 case itype_liftglove:
10840 {
10841 do_liftglove(itemid,false);
10842 dowpn = -1;
10843 ret = false;
10844 break;
10845 }
10846 case itype_potion:
10847 {
10848
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10849 {
10850 if(QMisc.miscsfx[sfxERROR])
10851 sfx(QMisc.miscsfx[sfxERROR]);
10852 return false;
10853 }
10854
10855 17 paymagiccost(itemid);
10856
10857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17 if(itm.misc1 || itm.misc2)
10858 {
10859 17 refill_what=REFILL_ALL;
10860 17 refill_why=itemid;
10861 17 StartRefill(REFILL_ALL);
10862 17 potion_life = game->get_life();
10863 17 potion_magic = game->get_magic();
10864
10865 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10866 //music_pause();
10867 17 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10868
2/2
✓ Branch 0 taken 4008 times.
✓ Branch 1 taken 17 times.
4025 while(refill())
10869 {
10870 4008 do_refill_waitframe();
10871 }
10872
10873 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10874 //music_resume();
10875 17 ret = false;
10876 17 }
10877
10878 17 break;
10879 }
10880 case itype_bottle:
10881 {
10882 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10883 {
10884 if(QMisc.miscsfx[sfxERROR])
10885 sfx(QMisc.miscsfx[sfxERROR]);
10886 return false;
10887 }
10888 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10889 return false;
10890
10891 size_t bind = game->get_bottle_slot(itm.misc1);
10892 bool paidmagic = false;
10893 if(itm.script)
10894 {
10895 paidmagic = true;
10896 paymagiccost(itemid);
10897
10898 ri = &(itemScriptData[itemid]);
10899 for ( int32_t q = 0; q < 1024; q++ )
10900 item_stack[itemid][q] = 0xFFFF;
10901 ri->Clear();
10902 item_doscript[itemid] = 1;
10903 itemscriptInitialised[itemid] = 0;
10904 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
10905 bind = game->get_bottle_slot(itm.misc1);
10906 }
10907 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
10908 if(bt)
10909 {
10910 word toFill[3] = { 0 };
10911 for(size_t q = 0; q < 3; ++q)
10912 {
10913 char c = bt->counter[q];
10914 if(c > -1)
10915 {
10916 if(bt->flags & (1<<q))
10917 {
10918 toFill[q] = (bt->amount[q]==100)
10919 ? game->get_maxcounter(c)
10920 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
10921 }
10922 else toFill[q] = bt->amount[q];
10923 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
10924 {
10925 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
10926 }
10927 }
10928 }
10929 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
10930 bool run = max > 0;
10931 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
10932 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
10933 else
10934 {
10935 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
10936 run = true;
10937 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
10938 run = true;
10939 }
10940 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
10941 {
10942 if(bt->flags & BTFLAG_CURESWJINX)
10943 {
10944 swordclk = 0;
10945 verifyAWpn();
10946 }
10947 if(bt->flags & BTFLAG_CUREITJINX)
10948 itemclk = 0;
10949 if(!paidmagic)
10950 paymagiccost(itemid);
10951 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10952 sfx(itm.usesound,pan(x.getInt()));
10953 for(size_t q = 0; q < 20; ++q)
10954 do_refill_waitframe();
10955 double inc = max/60.0; //1 second
10956 double xtra[3]{ 0 };
10957 for(size_t q = 0; q < 60; ++q)
10958 {
10959 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
10960 sfx(QMisc.miscsfx[sfxREFILL]);
10961 for(size_t j = 0; j < 3; ++j)
10962 {
10963 xtra[j] += inc;
10964 word f = floor(xtra[j]);
10965 xtra[j] -= f;
10966 if(toFill[j] > f)
10967 {
10968 toFill[j] -= f;
10969 game->change_counter(f,bt->counter[j]);
10970 }
10971 else if(toFill[j])
10972 {
10973 game->change_counter(toFill[j],bt->counter[j]);
10974 toFill[j] = 0;
10975 }
10976 }
10977 do_refill_waitframe();
10978 }
10979 for(size_t j = 0; j < 3; ++j)
10980 {
10981 if(toFill[j])
10982 {
10983 game->change_counter(toFill[j],bt->counter[j]);
10984 toFill[j] = 0;
10985 }
10986 }
10987 for(size_t q = 0; q < 20; ++q)
10988 do_refill_waitframe();
10989 game->set_bottle_slot(itm.misc1, bt->next_type);
10990 }
10991 }
10992
10993 dowpn = -1;
10994 ret = false;
10995 break;
10996 }
10997
10998 case itype_note:
10999 {
11000 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11001 {
11002 if(QMisc.miscsfx[sfxERROR])
11003 sfx(QMisc.miscsfx[sfxERROR]);
11004 return false;
11005 }
11006 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11007 {
11008 sfx(itm.usesound);
11009 donewmsg(itm.misc1);
11010 paymagiccost(itemid);
11011 }
11012 dowpn = -1;
11013 ret = false;
11014 break;
11015 }
11016
11017 case itype_mirror:
11018 doMirror(itemid);
11019 if(Quit)
11020 return false;
11021 ret = false;
11022 break;
11023
11024 case itype_rocs:
11025 {
11026
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2 times.
41 if(!do_jump(itemid,false)) return false;
11027 39 ret = false;
11028 }
11029 39 break;
11030
11031 case itype_letter:
11032 {
11033
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 if(current_item(itype_letter)==i_letter &&
11034
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11035
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].guy &&
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11037
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11038 3 checkbunny(itemid)
11039 )
11040 {
11041 3 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11042
11043
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(usedid != -1)
11044 3 getitem(usedid, true, true);
11045
11046 3 sfx(tmpscr[currscr<128?0:1].secretsfx);
11047 3 setupscreen();
11048 3 action=none; FFCore.setHeroAction(none);
11049 3 }
11050
11051 3 ret = false;
11052 }
11053 3 break;
11054
11055 case itype_whistle:
11056 {
11057 bool whistleflag;
11058
11059
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
102 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11060 {
11061 if(QMisc.miscsfx[sfxERROR])
11062 sfx(QMisc.miscsfx[sfxERROR]);
11063 return false;
11064 }
11065
11066 102 paymagiccost(itemid);
11067 102 sfx(itm.usesound);
11068
11069
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 47 times.
102 if(dir==up || dir==right)
11070 55 ++blowcnt;
11071 else
11072 47 --blowcnt;
11073
11074 102 int sfx_count = 0;
11075
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18462 times.
✓ Branch 6 taken 18360 times.
✓ Branch 7 taken 102 times.
18462 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11076 {
11077 18360 sfx_count += 1;
11078 18360 advanceframe(true);
11079
11080
1/2
✓ Branch 0 taken 18360 times.
✗ Branch 1 not taken.
18360 if(Quit)
11081 return false;
11082 }
11083
11084
7/14
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 102 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 102 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 102 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 102 times.
✗ Branch 13 not taken.
102 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11085
11086
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 8 times.
102 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11087 8 didstuff |= did_whistle;
11088
11089
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
102 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11090 10 return false;
11091
11092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11093
11094
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
92 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11095
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 || (tmpscr->flags7&fWHISTLEPAL))
11096 {
11097 25 whistleclk=0; // signal to start drying lake or doing other stuff
11098 25 }
11099 else
11100 {
11101 67 int32_t where = itm.misc1;
11102
11103
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(where>right) where=dir^1;
11104
11105
4/6
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 41 times.
108 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11106
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11107
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 41 times.
✗ Branch 11 not taken.
82 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11108
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 41 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 41 times.
✗ Branch 9 not taken.
41 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11109
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 (zfix)0,
11110 wWind,
11111 0, //type
11112 0,
11113 41 where,
11114
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11115
11116 67 whistleitem=itemid;
11117 }
11118
11119 92 ret = false;
11120 }
11121 92 break;
11122
11123 case itype_bomb:
11124 {
11125 //Remote detonation
11126
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 402 times.
402 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11127 {
11128 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11129
11130 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11131 {
11132 //If this ever needs a version check, in the future. -z
11133 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11134 {
11135 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11136 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11137 }
11138 ew->misc=50;
11139 ew->clk=ew->misc-3;
11140 ew->id=wBomb;
11141 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11142 }
11143
11144 deselectbombs(false);
11145 return false;
11146 }
11147
11148
2/4
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 402 times.
402 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11149 {
11150 if(QMisc.miscsfx[sfxERROR])
11151 sfx(QMisc.miscsfx[sfxERROR]);
11152 return false;
11153 }
11154
11155 402 paymagiccost(itemid);
11156
11157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 if(itm.misc1>0) // If not remote bombs
11158 402 deselectbombs(false);
11159
11160
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 360 times.
402 if(isdungeon())
11161 {
11162
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 wy=zc_max(wy,16);
11163 360 }
11164
11165
4/8
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 402 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 402 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 402 times.
✗ Branch 7 not taken.
804 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11166
2/4
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 402 times.
✗ Branch 3 not taken.
402 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11167 402 sfx(WAV_PLACE,pan(wx));
11168 }
11169 402 break;
11170
11171 case itype_sbomb:
11172 {
11173 //Remote detonation
11174
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11175 {
11176 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11177
11178 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11179 {
11180 ew->misc=50;
11181 ew->clk=ew->misc-3;
11182 ew->id=wSBomb;
11183 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11184 }
11185
11186 deselectbombs(true);
11187 return false;
11188 }
11189
11190
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11191 {
11192 if(QMisc.miscsfx[sfxERROR])
11193 sfx(QMisc.miscsfx[sfxERROR]);
11194 return false;
11195 }
11196
11197 12 paymagiccost(itemid);
11198
11199
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itm.misc1>0) // If not remote bombs
11200 12 deselectbombs(true);
11201
11202
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true));
11203 12 sfx(WAV_PLACE,pan(wx));
11204 }
11205 12 break;
11206
11207 case itype_wand:
11208 {
11209
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 406 times.
611 if(Lwpns.idCount(wMagic))
11210 {
11211 205 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11212 205 return false;
11213 }
11214
11215 406 int32_t bookid = current_item_id(itype_book);
11216
3/4
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 341 times.
406 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11217
11218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
406 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11219 {
11220 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11221 return false;
11222 }
11223
11224
3/6
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 406 times.
✗ Branch 5 not taken.
406 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11225 {
11226 if(QMisc.miscsfx[sfxERROR])
11227 sfx(QMisc.miscsfx[sfxERROR]);
11228 return false;
11229 }
11230
11231
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 3 times.
406 if(Lwpns.idCount(wBeam))
11232 3 Lwpns.del(Lwpns.idFirst(wBeam));
11233
11234 int32_t type, pow;
11235
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 300 times.
406 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11236 {
11237
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 65 times.
106 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11238
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 65 times.
106 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11239 106 }
11240 else
11241 {
11242
2/4
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
300 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11243
2/4
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
300 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11244 }
11245
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 812 times.
✓ Branch 4 taken 406 times.
✓ Branch 5 taken 406 times.
812 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
812 if(dir!=(i^1))
11247 {
11248
5/10
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 406 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 406 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 406 times.
✗ Branch 9 not taken.
406 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11249
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 341 times.
406 if(paybook)
11250 341 magic->linkedItem = bookid;
11251 //magic->dir = this->dir; //Save player dir for special weapons.
11252 406 Lwpns.add(magic);
11253 406 }
11254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11255 406 paymagiccost(itemid);
11256 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11257
11258
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 341 times.
406 if(paybook)
11259 341 paymagiccost(current_item_id(itype_book));
11260
11261
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 65 times.
406 if(bookid != -1)
11262 {
11263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11264 {
11265 sfx(itemsbuf[bookid].misc2,pan(wx));
11266 }
11267 else
11268 {
11269 341 sfx(itm.usesound,pan(wx));
11270 }
11271 341 }
11272 else
11273 65 sfx(itm.usesound,pan(wx));
11274 }
11275 /*
11276 // Fireball Wand
11277 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11278 switch (dir)
11279 {
11280 case up:
11281 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11282 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11283 break;
11284 case down:
11285 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11286 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11287 break;
11288 case left:
11289 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11290 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11291 break;
11292 case right:
11293 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11294 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11295 break;
11296 }
11297 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11298 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11299 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11300 */
11301 406 break;
11302
11303 case itype_sword:
11304 {
11305
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7244 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11306 {
11307 if(QMisc.miscsfx[sfxERROR])
11308 sfx(QMisc.miscsfx[sfxERROR]);
11309 return false;
11310 }
11311
11312
4/4
✓ Branch 0 taken 1357 times.
✓ Branch 1 taken 5887 times.
✓ Branch 2 taken 1357 times.
✓ Branch 3 taken 5887 times.
7244 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11313 {
11314 1357 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11315 1357 return false;
11316 }
11317
11318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5887 times.
5887 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11319 5887 paymagiccost(itemid);
11320 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11321 float temppower;
11322
11323
1/2
✓ Branch 0 taken 5887 times.
✗ Branch 1 not taken.
5887 if(itm.flags & ITEM_FLAG2)
11324 {
11325 5887 temppower=game->get_hero_dmgmult()*itm.power;
11326 5887 temppower=temppower*itm.misc2;
11327 5887 temppower=temppower/100;
11328 5887 }
11329 else
11330 {
11331 temppower = game->get_hero_dmgmult()*itm.misc2;
11332 }
11333
11334 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11335 //Add weapon script to sword beams.
11336
5/10
✓ Branch 0 taken 5887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5887 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5887 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5887 times.
✗ Branch 9 not taken.
5887 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11337 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11338 //w->weaponscript = itm.weaponscript;
11339 //w->canrunscript = 0;
11340 5887 sfx(WAV_BEAM,pan(wx));
11341 }
11342 5887 break;
11343
11344 case itype_candle:
11345 {
11346 554 int32_t countid = itemid;
11347
1/2
✓ Branch 0 taken 554 times.
✗ Branch 1 not taken.
554 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11348 554 countid = -itype_candle;
11349
5/6
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 545 times.
554 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11350 {
11351 9 return false;
11352 }
11353
11354
3/4
✓ Branch 0 taken 545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 511 times.
545 if(Lwpns.idCount(wFire) >= (itm.misc3 < 1 ? 2 : itm.misc3))
11355 {
11356 34 return false;
11357 }
11358
11359
2/4
✓ Branch 0 taken 511 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 511 times.
511 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11360 {
11361 if(QMisc.miscsfx[sfxERROR])
11362 sfx(QMisc.miscsfx[sfxERROR]);
11363 return false;
11364 }
11365
11366 511 paymagiccost(itemid);
11367
11368
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 92 times.
511 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11369
11370
4/8
✓ Branch 0 taken 511 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 511 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 511 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 511 times.
✗ Branch 7 not taken.
1022 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11371 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11372 511 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11373
2/4
✓ Branch 0 taken 511 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 511 times.
✗ Branch 3 not taken.
511 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11374 511 sfx(itm.usesound,pan(wx));
11375 511 attack=wFire;
11376 }
11377 511 break;
11378
11379 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11380 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11381 {
11382 int32_t wtype = wScript1 + (itm.family-itype_script1);
11383 if(Lwpns.idCount(wtype))
11384 return false;
11385
11386 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11387 {
11388 if(QMisc.miscsfx[sfxERROR])
11389 sfx(QMisc.miscsfx[sfxERROR]);
11390 return false;
11391 }
11392
11393 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11394 paymagiccost(itemid);
11395
11396 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11397 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11398 sfx(itm.usesound,pan(wx));
11399 }
11400 break;
11401
11402 case itype_icerod:
11403 {
11404 if(Lwpns.idCount(wIce))
11405 return false;
11406
11407 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11408 {
11409 if(QMisc.miscsfx[sfxERROR])
11410 sfx(QMisc.miscsfx[sfxERROR]);
11411 return false;
11412 }
11413
11414 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11415 paymagiccost(itemid);
11416
11417 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11418 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11419 sfx(itm.usesound,pan(wx));
11420 }
11421 break;
11422
11423 case itype_arrow:
11424 {
11425
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 221 times.
226 if(Lwpns.idCount(wArrow) > itm.misc2)
11426 5 return false;
11427
11428
2/4
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
221 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11429 {
11430 if(QMisc.miscsfx[sfxERROR])
11431 sfx(QMisc.miscsfx[sfxERROR]);
11432 return false;
11433 }
11434
11435 221 paymagiccost(itemid);
11436
11437
6/12
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 221 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 221 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 221 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 221 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 221 times.
✗ Branch 11 not taken.
221 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11438 221 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11439 221 sfx(itm.usesound,pan(wx));
11440 }
11441 221 break;
11442
11443 case itype_bait:
11444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11445 return false;
11446
11447
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11448 {
11449 if(QMisc.miscsfx[sfxERROR])
11450 sfx(QMisc.miscsfx[sfxERROR]);
11451 return false;
11452 }
11453
11454 6 paymagiccost(itemid);
11455 6 sfx(itm.usesound,pan(wx));
11456
11457
3/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if(tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
11458 {
11459
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,iBait,ipDUMMY+ipFADE,0));
11460 6 fadeclk=66;
11461 6 dismissmsg();
11462 6 clear_bitmap(pricesdisplaybuf);
11463 6 set_clip_state(pricesdisplaybuf, 1);
11464 // putscr(scrollbuf,0,0,tmpscr);
11465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11466 6 removeItemsOfFamily(game,itemsbuf,itype_bait);
11467 6 verifyBothWeapons();
11468 6 sfx(tmpscr->secretsfx);
11469 6 return false;
11470 }
11471
11472 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11473 break;
11474
11475 case itype_brang:
11476 {
11477
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 4159 times.
4308 if(Lwpns.idCount(wBrang) > itm.misc2)
11478 149 return false;
11479
11480
2/4
✓ Branch 0 taken 4159 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4159 times.
4159 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11481 {
11482 if(QMisc.miscsfx[sfxERROR])
11483 sfx(QMisc.miscsfx[sfxERROR]);
11484 return false;
11485 }
11486
11487 4159 paymagiccost(itemid);
11488 4159 current_item_power(itype_brang);
11489
6/12
✓ Branch 0 taken 4159 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4159 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4159 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4159 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4159 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4159 times.
✗ Branch 11 not taken.
4159 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11490 }
11491 4159 break;
11492
11493 case itype_hookshot:
11494 case itype_switchhook:
11495 {
11496
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(inlikelike || Lwpns.idCount(wHookshot))
11497 return false;
11498
11499
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11500 {
11501 if(QMisc.miscsfx[sfxERROR])
11502 sfx(QMisc.miscsfx[sfxERROR]);
11503 return false;
11504 }
11505 8 bool sw = itm.family == itype_switchhook;
11506
11507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(sw && (itm.flags&ITEM_FLAG8))
11508 switchhook_cost_item = itemid;
11509 8 else paymagiccost(itemid);
11510
11511 8 bool use_hookshot=true;
11512 8 bool hit_hs = false, hit_solid = false, insta_switch = false;
11513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11514 8 int32_t cpos = -1, ffcpos = -1;
11515
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 8 times.
16 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11516 {
11517
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(dir==up)
11518 {
11519
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11520 hit_hs = true;
11521 2 }
11522
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 else if(dir==down)
11523 {
11524
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11525 hit_hs = true;
11526 1 }
11527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(dir==left)
11528 {
11529 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11530 hit_hs = true;
11531 }
11532
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 else if(dir==right)
11533 {
11534
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11535 hit_hs = true;
11536 5 }
11537 //Diagonal Hookshot (6)
11538 else if(dir==r_down)
11539 {
11540 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11541 hit_hs = true;
11542 }
11543 else if(dir==l_down)
11544 {
11545 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11546 hit_hs = true;
11547 }
11548 else if(dir==r_up)
11549 {
11550 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11551 hit_hs = true;
11552 }
11553 else if(dir==l_up)
11554 {
11555 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11556 hit_hs = true;
11557 }
11558 8 }
11559
6/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
8 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11560 hit_solid = true;
11561
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(hit_hs)
11562 {
11563 if(sw)
11564 insta_switch = true; //switch immediately
11565 else use_hookshot = false; //No hooking against grabbable
11566 }
11567
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(hit_solid && !insta_switch)
11568 use_hookshot = false;
11569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(use_hookshot)
11570 {
11571 8 int32_t hookitem = itm.fam_type;
11572 8 int32_t hookpower = itm.power;
11573 8 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11574
11575
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!Lwpns.has_space())
11576 {
11577 Lwpns.del(0);
11578 }
11579
11580
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!Lwpns.has_space(2))
11581 {
11582 Lwpns.del(0);
11583 }
11584
11585
3/9
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
8 switch(dir)
11586 {
11587 case up:
11588 {
11589 2 hookshot_used=true;
11590 2 hs_switcher = sw;
11591
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11592
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11593 2 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11594
5/10
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
4 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11595
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11596 2 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11597 2 hs_startx=wx;
11598 2 hs_starty=wy-4;
11599 }
11600 2 break;
11601
11602 case down:
11603 {
11604 1 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11605 1 hookshot_used=true;
11606 1 hs_switcher = sw;
11607
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11608
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11609 1 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11610
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11611
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11612 1 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11613 1 hs_startx=wx;
11614 1 hs_starty=wy;
11615 }
11616 1 break;
11617
11618 case left:
11619 {
11620 hookshot_used=true;
11621 hs_switcher = sw;
11622 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11623 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11624 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11625 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11626 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11627 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11628 hs_startx=wx-4;
11629 hs_starty=wy;
11630 }
11631 break;
11632
11633 case right:
11634 {
11635 5 hookshot_used=true;
11636 5 hs_switcher = sw;
11637
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
10 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11638
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11639 5 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11640
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
10 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11641
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11642 5 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11643 5 hs_startx=wx+4;
11644 5 hs_starty=wy;
11645 }
11646 5 break;
11647 //Diagonal Hookshot (7)
11648 case r_down:
11649 {
11650 hookshot_used=true;
11651 hs_switcher = sw;
11652 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11653 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11654 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11655 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11656 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11657 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11658 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11659 hs_startx=wx+4;
11660 hs_starty=wy;
11661 }
11662 break;
11663
11664 case r_up:
11665 {
11666 hookshot_used=true;
11667 hs_switcher = sw;
11668 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11669 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11670 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11671 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11672 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11673 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11674 hs_startx=wx+4;
11675 hs_starty=wy;
11676 }
11677 break;
11678
11679 case l_down:
11680 {
11681 hookshot_used=true;
11682 hs_switcher = sw;
11683 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11684 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11685 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11686 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11687 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11688 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11689 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11690 hs_startx=wx+4;
11691 hs_starty=wy;
11692 }
11693 break;
11694
11695 case l_up:
11696 {
11697 hookshot_used=true;
11698 hs_switcher = sw;
11699 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11700 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11701 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11702 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11703 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11704 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11705 hs_startx=wx+4;
11706 hs_starty=wy;
11707 }
11708 break;
11709 }
11710 8 hookshot_frozen=true;
11711 8 }
11712
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(insta_switch)
11713 {
11714 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11715 if (cpos > -1) hooked_combopos = cpos;
11716 if (ffcpos > -1)
11717 {
11718 switching_object = &(tmpscr->ffcs[ffcpos]);
11719 switching_object->switch_hooked = true;
11720 }
11721 w->misc=2;
11722 w->step=0;
11723 doSwitchHook(itm.misc5);
11724 if(itm.usesound2)
11725 sfx(itm.usesound2,pan(int32_t(x)));
11726 else if(QMisc.miscsfx[sfxSWITCHED])
11727 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11728 stop_sfx(itm.usesound);
11729 }
11730 }
11731 8 break;
11732
11733 case itype_dinsfire:
11734 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11735 return false;
11736
11737 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11738 {
11739 if(QMisc.miscsfx[sfxERROR])
11740 sfx(QMisc.miscsfx[sfxERROR]);
11741 return false;
11742 }
11743
11744 paymagiccost(itemid);
11745 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11746 else {action=casting; FFCore.setHeroAction(casting);}
11747 magicitem=itemid;
11748 break;
11749
11750 case itype_faroreswind:
11751 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11752 return false;
11753
11754 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11755 {
11756 if(QMisc.miscsfx[sfxERROR])
11757 sfx(QMisc.miscsfx[sfxERROR]);
11758 return false;
11759 }
11760
11761 paymagiccost(itemid);
11762 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11763 else {action=casting; FFCore.setHeroAction(casting);}
11764 magicitem=itemid;
11765 break;
11766
11767 case itype_nayruslove:
11768 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11769 return false;
11770
11771 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11772 {
11773 if(QMisc.miscsfx[sfxERROR])
11774 sfx(QMisc.miscsfx[sfxERROR]);
11775 return false;
11776 }
11777
11778 paymagiccost(itemid);
11779 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11780 else {action=casting; FFCore.setHeroAction(casting);}
11781 magicitem=itemid;
11782 break;
11783
11784 case itype_cbyrna:
11785 {
11786 //Beams already deployed
11787 if(Lwpns.idCount(wCByrna))
11788 {
11789 stopCaneOfByrna();
11790 return false;
11791 }
11792
11793 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11794 {
11795 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11796 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11797 return false;
11798 }
11799
11800 paymagiccost(itemid);
11801 last_cane_of_byrna_item_id = itemid;
11802 //zprint("itm.misc3: %d\n", itm.misc3);
11803 for(int32_t i=0; i<itm.misc3; i++)
11804 {
11805 //byrna weapons are added here
11806 //space them apart
11807 //zprint("Added byrna weapon %d.\n", i);
11808 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11809 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11810 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11811 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11812 //wx += cos(2 * PI / (itm.misc3-i));
11813 //wy += sin(2 * PI / (itm.misc3-i));
11814 }
11815 if(!(Lwpns.idCount(wCByrna)))
11816 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11817 }
11818 break;
11819
11820 case itype_clock:
11821 {
11822 ret = false;
11823 if(!(itm.flags & ITEM_FLAG1))
11824 break; //Passive clock, don't use
11825 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11826 break;
11827 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11828 {
11829 if(QMisc.miscsfx[sfxERROR])
11830 sfx(QMisc.miscsfx[sfxERROR]);
11831 return false;
11832 }
11833
11834 paymagiccost(itemid);
11835
11836 setClock(watch=true);
11837
11838 for(int32_t i=0; i<eMAXGUYS; i++)
11839 clock_zoras[i]=0;
11840
11841 clockclk=itm.misc1;
11842 sfx(itm.usesound);
11843 break;
11844 }
11845 case itype_killem:
11846 {
11847 ret = false;
11848 if(!(itm.flags & ITEM_FLAG1))
11849 break; //Passive killemall, don't use
11850
11851 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11852 || !can_kill_em_all()) //No enemies onscreen
11853 {
11854 if(QMisc.miscsfx[sfxERROR])
11855 sfx(QMisc.miscsfx[sfxERROR]);
11856 return false;
11857 }
11858
11859 paymagiccost(itemid);
11860
11861 kill_em_all();
11862 sfx(itm.usesound);
11863 break;
11864 }
11865 case itype_refill:
11866 {
11867 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11868 {
11869 if(QMisc.miscsfx[sfxERROR])
11870 sfx(QMisc.miscsfx[sfxERROR]);
11871 return false;
11872 }
11873
11874 bool did_something = false;
11875
11876 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
11877 {
11878 if(swordclk)
11879 did_something = true;
11880 swordclk = 0;
11881 verifyAWpn();
11882 }
11883 for(auto q = 0; q < 5; ++q)
11884 {
11885 auto ctr = itm.misc(q);
11886 if(unsigned(ctr) >= MAX_COUNTERS)
11887 continue;
11888 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
11889 if(!amnt) continue;
11890 bool gradual = itm.flags & ITEM_FLAG2;
11891 if(amnt > 0)
11892 {
11893 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
11894 {
11895 //Can't *do* anything... skip
11896 continue;
11897 }
11898 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
11899 {
11900 //Can't do anything unless affecting dcounter
11901 gradual = true;
11902 }
11903 }
11904 else //Negative
11905 {
11906 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
11907 {
11908 //Can't *do* anything... skip
11909 continue;
11910 }
11911 if(game->get_counter(ctr) <= 0)
11912 {
11913 //Can't do anything unless affecting dcounter
11914 gradual = true;
11915 }
11916 }
11917 did_something = true;
11918 if(gradual) //Gradual
11919 {
11920 game->change_dcounter(amnt, ctr);
11921 }
11922 else
11923 {
11924 game->change_counter(amnt, ctr);
11925 }
11926 }
11927 if(!did_something)
11928 {
11929 if(QMisc.miscsfx[sfxERROR])
11930 sfx(QMisc.miscsfx[sfxERROR]);
11931 return false;
11932 }
11933 paymagiccost(itemid);
11934 sfx(itm.usesound);
11935 ret = false;
11936 break;
11937 }
11938
11939 default:
11940 15 ret = false;
11941 15 }
11942
11943
2/2
✓ Branch 0 taken 11755 times.
✓ Branch 1 taken 17 times.
11772 if(itm.flags & ITEM_DOWNGRADE)
11944 {
11945 17 game->set_item(itemid,false);
11946
11947 // Maybe Item Override has allowed the same item in both slots?
11948
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(Bwpn == itemid)
11949 {
11950 Bwpn = 0;
11951 game->forced_bwpn = -1;
11952 verifyBWpn();
11953 }
11954
11955
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(Awpn == itemid)
11956 {
11957 Awpn = 0;
11958 game->forced_awpn = -1;
11959 verifyAWpn();
11960 }
11961
11962
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(Xwpn == itemid)
11963 {
11964 Xwpn = 0;
11965 game->forced_xwpn = -1;
11966 verifyXWpn();
11967 }
11968
11969
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(Ywpn == itemid)
11970 {
11971 Ywpn = 0;
11972 game->forced_ywpn = -1;
11973 verifyYWpn();
11974 }
11975 17 }
11976
11977 11772 return ret;
11978 13561 }
11979
11980
11981 448353 bool HeroClass::doattack()
11982 {
11983 //int32_t s = BSZ ? 0 : 11;
11984 448353 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
11985
11986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 448353 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
448353 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
11987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 448353 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
448353 if(attack==wBugNet && bugnetid!=-1)
11988 {
11989 if(++attackclk >= NET_CLK_TOTAL)
11990 return false;
11991
11992 return true;
11993 }
11994
11995 // Abort attack if attackclk has run out and:
11996 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
11997 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
11998
11999
4/6
✓ Branch 0 taken 25274 times.
✓ Branch 1 taken 423079 times.
✓ Branch 2 taken 25274 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 994 times.
449347 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12000
8/12
✓ Branch 0 taken 21341 times.
✓ Branch 1 taken 3933 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21341 times.
✓ Branch 4 taken 24663 times.
✓ Branch 5 taken 611 times.
✓ Branch 6 taken 24280 times.
✓ Branch 7 taken 383 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 994 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
25274 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12001 {
12002 25274 tapping=false;
12003 25274 return false;
12004 }
12005
12006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423079 times.
423079 if(attackclk>29)
12007 {
12008 tapping=false;
12009 return false;
12010 }
12011
12012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423079 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423079 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12014 // An attack can be "walked out-of" after 8 frames, unless it's:
12015 // * a sword stab
12016 // * a hammer pound
12017 // * a wand thrust
12018 // * a candle thrust
12019 // * a cane thrust
12020 // In which case it should continue.
12021
8/8
✓ Branch 0 taken 18877 times.
✓ Branch 1 taken 404202 times.
✓ Branch 2 taken 48838 times.
✓ Branch 3 taken 29961 times.
✓ Branch 4 taken 383763 times.
✓ Branch 5 taken 50400 times.
✓ Branch 6 taken 76968 times.
✓ Branch 7 taken 306795 times.
500047 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12022
4/6
✓ Branch 0 taken 76968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6642 times.
✓ Branch 3 taken 70326 times.
✓ Branch 4 taken 6642 times.
✗ Branch 5 not taken.
76968 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76968 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12024
2/2
✓ Branch 0 taken 76968 times.
✓ Branch 1 taken 6642 times.
70326 && (attack != wBugNet) && attackclk>7))
12025 {
12026
8/8
✓ Branch 0 taken 26984 times.
✓ Branch 1 taken 1146 times.
✓ Branch 2 taken 26076 times.
✓ Branch 3 taken 908 times.
✓ Branch 4 taken 24807 times.
✓ Branch 5 taken 1269 times.
✓ Branch 6 taken 1178 times.
✓ Branch 7 taken 23629 times.
125806 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12027 {
12028 4501 lstep = s;
12029 4501 return false;
12030 }
12031 23629 }
12032
12033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394108 times.
394108 if(charging==0)
12034 {
12035 394108 lstep=0;
12036 394108 }
12037
12038 // Work out the sword charge-up delay
12039 394108 int32_t magiccharge = 192, normalcharge = 64;
12040 394108 int32_t itemid = current_item_id(itype_chargering);
12041
12042
1/2
✓ Branch 0 taken 394108 times.
✗ Branch 1 not taken.
394108 if(itemid>=0)
12043 {
12044 normalcharge = itemsbuf[itemid].misc1;
12045 magiccharge = itemsbuf[itemid].misc2;
12046 }
12047
12048 394108 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12049
12050 394108 bool doCharge=true;
12051
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 394108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
394108 if(z!=0 && fakez != 0)
12052 doCharge=false;
12053
2/2
✓ Branch 0 taken 306795 times.
✓ Branch 1 taken 87313 times.
394108 if(attack==wSword)
12054 {
12055
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 306795 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
306795 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12056 306795 doCharge=false;
12057 else if(charging<=normalcharge)
12058 {
12059 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12060 doCharge=false;
12061 }
12062 306795 }
12063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87313 times.
87313 else if(attack==wHammer)
12064 {
12065 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12066 doCharge=false;
12067 else if(charging<=normalcharge)
12068 {
12069 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12070 doCharge=false;
12071 }
12072 }
12073 else
12074 87313 doCharge=false;
12075
12076 // Now work out the magic cost
12077 394108 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12078
12079 // charging up weapon...
12080 //
12081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394108 times.
394108 if(doCharge)
12082 {
12083 // Increase charging while holding down button.
12084 if(spins==0 && charging<magiccharge)
12085 charging++;
12086
12087 // Once a charging threshold is reached, play the sound.
12088 if(charging==normalcharge)
12089 {
12090 paymagiccost(itemid); //!DIMITODO: Can this underflow or even just do it even if you don't have magic?
12091 sfx(WAV_ZN1CHARGE,pan(x.getInt()));
12092 }
12093 else if(charging==magiccharge)
12094 {
12095 itemid = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12096
12097 if(itemid>-1 && checkbunny(itemid) && checkmagiccost(itemid))
12098 {
12099 paymagiccost(itemid);
12100 charging++; // charging>magiccharge signifies a successful supercharge.
12101 sfx(WAV_ZN1CHARGE2,pan(x.getInt()));
12102 }
12103 }
12104 }
12105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 394108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
394108 else if(attack==wCByrna && byrnaid!=-1)
12106 {
12107 if(!(itemsbuf[byrnaid].wpn))
12108 {
12109 attack = wNone;
12110 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12111 }
12112
12113 bool beamcount = false;
12114
12115 for(int32_t i=0; i<Lwpns.Count(); i++)
12116 {
12117 weapon *w = ((weapon*)Lwpns.spr(i));
12118
12119 if(w->id==wCByrna)
12120 {
12121 beamcount = true;
12122 break;
12123 }
12124 }
12125
12126 // If beams already deployed, remove them
12127 if(!attackclk && beamcount)
12128 {
12129 return startwpn(attackid); // Remove beams instantly
12130 }
12131
12132 // Otherwise, continue
12133 ++attackclk;
12134 }
12135 else
12136 {
12137 394108 ++attackclk;
12138
12139
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 394108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
394108 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12140 {
12141 ++attackclk; // Won't continue charging
12142 charging=0;
12143 }
12144
12145 // Faster if spinning.
12146
1/2
✓ Branch 0 taken 394108 times.
✗ Branch 1 not taken.
394108 if(spins>0)
12147 ++attackclk;
12148
12149 // Even faster if hurricane spinning.
12150
1/2
✓ Branch 0 taken 394108 times.
✗ Branch 1 not taken.
394108 if(spins>5)
12151 attackclk+=2;
12152
12153 // If at a charging threshold, do a charged attack.
12154
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 394108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
394108 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12155 {
12156 if(attack==wSword)
12157 {
12158 spins=(charging>magiccharge ? (itemsbuf[current_item_id(itype_spinscroll2)].misc1*4)-3
12159 : (itemsbuf[current_item_id(itype_spinscroll)].misc1*4)+1);
12160 attackclk=1;
12161 sfx(itemsbuf[current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
12162 }
12163 /*
12164 else if(attack==wWand)
12165 {
12166 //Not reachable.. yet
12167 spins=1;
12168 }
12169 */
12170 else if(attack==wHammer && sideviewhammerpound())
12171 {
12172 spins=1; //signifies the quake hammer
12173 bool super = (charging>magiccharge && current_item(itype_quakescroll2));
12174 sfx(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].usesound,pan(x.getInt()));
12175 quakeclk=(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc1);
12176
12177 // general area stun
12178 for(int32_t i=0; i<GuyCount(); i++)
12179 {
12180 if(!isflier(GuyID(i)))
12181 {
12182 StunGuy(i,(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc2)-
12183 distance(x,y,GuyX(i),GuyY(i)));
12184 }
12185 }
12186 }
12187 }
12188
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 394108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
394108 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12189 charging++;
12190
12191
7/8
✓ Branch 0 taken 6514 times.
✓ Branch 1 taken 387594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387594 times.
✓ Branch 4 taken 8554 times.
✓ Branch 5 taken 379040 times.
✓ Branch 6 taken 287900 times.
✓ Branch 7 taken 106208 times.
394108 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12192 106208 charging=0;
12193
12194
1/2
✓ Branch 0 taken 394108 times.
✗ Branch 1 not taken.
394108 if(attackclk>=SWORDCHARGEFRAME)
12195 tapping = false;
12196 }
12197
12198
6/8
✓ Branch 0 taken 31083 times.
✓ Branch 1 taken 363025 times.
✓ Branch 2 taken 554 times.
✓ Branch 3 taken 30529 times.
✓ Branch 4 taken 554 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 554 times.
394108 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12199 {
12200 554 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12201 }
12202
12203 393554 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12204
12205
5/12
✓ Branch 0 taken 367995 times.
✓ Branch 1 taken 25559 times.
✓ Branch 2 taken 28387 times.
✓ Branch 3 taken 339608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28387 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
393554 if(attackclk==13 || (attackclk==7 && spins>1 && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12206 {
12207
12208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25559 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12209
2/2
✓ Branch 0 taken 25541 times.
✓ Branch 1 taken 18 times.
25559 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12210
12211
3/4
✓ Branch 0 taken 25541 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25541 times.
25559 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12212 {
12213 25541 templife=templife*game->get_maxlife();
12214 25541 templife=templife/100;
12215 25541 }
12216 else
12217 {
12218 18 templife*=game->get_hp_per_heart();
12219 }
12220
12221
2/2
✓ Branch 0 taken 14101 times.
✓ Branch 1 taken 11458 times.
25559 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12222 25559 int32_t perilid = current_item_id(itype_perilscroll);
12223
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25559 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12224 && checkbunny(perilid) && checkmagiccost(perilid)
12225 // Must actually be able to shoot sword beams
12226 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12227 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12228
12229
3/4
✓ Branch 0 taken 21473 times.
✓ Branch 1 taken 4086 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21473 times.
25559 if(attack==wSword && !tapping)
12230 {
12231
3/4
✓ Branch 0 taken 21473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7253 times.
✓ Branch 3 taken 14220 times.
21473 if(perilbeam || normalbeam)
12232 {
12233
1/2
✓ Branch 0 taken 7253 times.
✗ Branch 1 not taken.
7253 if(attackclk==7)
12234 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12235
12236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7253 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7253 if(perilbeam && !normalbeam)
12237 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12238
12239 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12240 // a way to make the peril/cross beam item's power stat influence the strength
12241 // of the peril/cross beam...
12242 7253 startwpn(attackid);
12243 7253 }
12244 14220 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12245 21473 }
12246
12247
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 611 times.
25559 if(attack==wWand)
12248 611 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12249
12250
4/6
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 25168 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 391 times.
✗ Branch 5 not taken.
25559 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12251 startwpn(attackid);
12252
12253
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25559 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12254 startwpn(attackid);
12255 25559 }
12256
12257
2/2
✓ Branch 0 taken 368208 times.
✓ Branch 1 taken 25346 times.
393554 if(attackclk==14)
12258 25346 lstep = s;
12259
12260 393554 return true;
12261 423883 }
12262
12263 4664670 bool HeroClass::can_attack()
12264 {
12265
4/4
✓ Branch 0 taken 4604806 times.
✓ Branch 1 taken 59864 times.
✓ Branch 2 taken 3352474 times.
✓ Branch 3 taken 1252332 times.
4664670 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12266
4/6
✓ Branch 0 taken 4664670 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4642468 times.
✓ Branch 3 taken 22202 times.
✓ Branch 4 taken 4642468 times.
✗ Branch 5 not taken.
5019206 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12267
4/8
✓ Branch 0 taken 4642468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4642468 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4642468 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4642468 times.
✗ Branch 7 not taken.
4642468 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12268
3/4
✓ Branch 0 taken 4642468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3831555 times.
✓ Branch 3 taken 810913 times.
4642468 || ((action==attacking||action==sideswimattacking)
12269
2/2
✓ Branch 0 taken 177268 times.
✓ Branch 1 taken 4465200 times.
4642468 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12270
2/2
✓ Branch 0 taken 4642468 times.
✓ Branch 1 taken 177268 times.
4642468 && charging!=0))
12271 {
12272 376738 return false;
12273 }
12274
12275 4642468 int32_t r = (isdungeon()) ? 16 : 0;
12276 4642468 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12277
12278
4/5
✓ Branch 0 taken 1487020 times.
✓ Branch 1 taken 3155448 times.
✓ Branch 2 taken 1345024 times.
✓ Branch 3 taken 1810424 times.
✗ Branch 4 not taken.
4642468 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12279 {
12280 case up:
12281 case down:
12282
2/2
✓ Branch 0 taken 1314000 times.
✓ Branch 1 taken 31024 times.
1345024 return !(y<(r2+r) || y>(160-r-r2));
12283
12284 case left:
12285 case right:
12286
2/2
✓ Branch 0 taken 1787932 times.
✓ Branch 1 taken 22492 times.
1810424 return !(x<(r2+r) || x>(240-r-r2));
12287 }
12288
12289 1487020 return true;
12290 5019206 }
12291
12292 2017 bool isRaftFlag(int32_t flag)
12293 {
12294
4/4
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 989 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 1010 times.
2017 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12295 }
12296
12297 2345672 void handle_lens_triggers(int32_t l_id)
12298 {
12299
2/2
✓ Branch 0 taken 2345048 times.
✓ Branch 1 taken 624 times.
2345672 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12300
2/2
✓ Branch 0 taken 2345672 times.
✓ Branch 1 taken 16419704 times.
18765376 for(auto layer = 0; layer < 7; ++layer)
12301 {
12302 16419704 mapscr* tmp = FFCore.tempScreens[layer];
12303
2/2
✓ Branch 0 taken 2889867904 times.
✓ Branch 1 taken 16419704 times.
2906287608 for(auto pos = 0; pos < 176; ++pos)
12304 {
12305 2889867904 newcombo const& cmb = combobuf[tmp->data[pos]];
12306
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2889867904 times.
✓ Branch 2 taken 2889867904 times.
✗ Branch 3 not taken.
2889867904 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12307 2889867904 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12308 {
12309 do_trigger_combo(layer, pos);
12310 }
12311 2889867904 }
12312 16419704 }
12313
2/2
✓ Branch 0 taken 2336981 times.
✓ Branch 1 taken 8691 times.
2345672 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12314 {
12315 8691 word c = tmpscr->numFFC();
12316
2/2
✓ Branch 0 taken 8691 times.
✓ Branch 1 taken 127582 times.
136273 for(word i=0; i<c; i++)
12317 {
12318 127582 ffcdata& ffc = tmpscr->ffcs[i];
12319 127582 newcombo const& cmb = combobuf[ffc.getData()];
12320
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 127582 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127582 times.
127582 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12321 127582 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12322 {
12323 do_trigger_combo_ffc(i);
12324 break;
12325 }
12326 127582 }
12327 8691 }
12328 2345672 }
12329
12330 2345672 void do_lens()
12331 {
12332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2345672 times.
2345672 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12333 {
12334 do_210_lens();
12335 return;
12336 }
12337
12338 2345672 int32_t wpnPressed = getWpnPressed(itype_lens);
12339
6/6
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 2345048 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 2345001 times.
✓ Branch 4 taken 114570 times.
✓ Branch 5 taken 2230431 times.
2345672 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12340
2/2
✓ Branch 0 taken 1985754 times.
✓ Branch 1 taken 359918 times.
2345672 if(itemid >= 0)
12341 {
12342
8/10
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 359472 times.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 387 times.
✓ Branch 6 taken 59 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✓ Branch 9 taken 52 times.
359918 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12343 {
12344
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 40 times.
52 if(lensid<0)
12345 {
12346 40 lensid=itemid;
12347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(itemsbuf[itemid].family == itype_lens)
12348 40 Hero.setLastLensID(itemid);
12349
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12350 40 }
12351
12352 52 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12353
12354
2/10
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
52 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12355 {
12356 //clear the item script stack for a new script
12357 //itemScriptData[(itemid & 0xFFF)].Clear();
12358 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12359 ri = &(itemScriptData[itemid]);
12360 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12361 ri->Clear();
12362 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12363 item_doscript[itemid] = 1;
12364 itemscriptInitialised[itemid] = 0;
12365 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12366 did_scriptl=true;
12367 }
12368
12369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12370 52 else lensclk = 12;
12371 52 }
12372 else
12373 {
12374 359866 did_scriptl=false;
12375
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 359294 times.
359866 if(!lensclk)
12376 {
12377
12378
2/2
✓ Branch 0 taken 359254 times.
✓ Branch 1 taken 40 times.
359294 if(lensid>-1)
12379 {
12380 40 lensid=-1;
12381 40 lensclk = 0;
12382
12383
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12384 40 }
12385 359294 }
12386 }
12387 359918 }
12388 2345672 handle_lens_triggers(lensid);
12389 2345672 }
12390 //Add 2.10 version check to call this
12391 void do_210_lens()
12392 {
12393 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12394
12395 if(itemid<0)
12396 return;
12397
12398 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12399 {
12400 if(lensid<0)
12401 {
12402 lensid=itemid;
12403
12404 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12405 }
12406
12407 paymagiccost(itemid, true);
12408
12409 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12410 {
12411 //clear the item script stack for a new script
12412 //itemScriptData[(itemid & 0xFFF)].Clear();
12413 ri = &(itemScriptData[itemid]);
12414 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12415 ri->Clear();
12416 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12417 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12418 item_doscript[itemid] = 1;
12419 itemscriptInitialised[itemid] = 0;
12420 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12421 did_scriptl=true;
12422 }
12423
12424 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12425 else lensclk = 12;
12426 }
12427 else
12428 {
12429 did_scriptl=false;
12430
12431 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12432 {
12433 lensid=-1;
12434 lensclk = 0;
12435
12436 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12437 }
12438 }
12439 }
12440
12441 764 void HeroClass::do_hopping()
12442 {
12443 764 do_lens();
12444
12445
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 732 times.
764 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12446 //Possible fix for exiting water in diagonal movement. -Z
12447 {
12448 32 int32_t flippers_id = current_item_id(itype_flippers);
12449
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 31 times.
32 if(diveclk>0)
12450 {
12451 1 --diveclk;
12452
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12453 {
12454 diveclk = itemsbuf[flippers_id].misc2;
12455 }
12456 1 }
12457
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 else if(DrunkrAbtn())
12458 {
12459 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12460 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12461
12462 if(global_diving==screen_diving)
12463 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12464 }
12465
12466
2/6
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
32 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12467 {
12468 32 SetSwim();
12469 32 hopclk = 0;
12470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if (!IsSideSwim())
12471 {
12472 32 charging = attackclk = 0;
12473 32 tapping = false;
12474 32 }
12475 32 }
12476 else
12477 {
12478 herostep();
12479
12480 if(!isDiving() || (frame&1))
12481 {
12482 switch(dir)
12483 {
12484 case up:
12485 y -= 1;
12486 break;
12487
12488 case down:
12489 y += 1;
12490 break;
12491
12492 case left:
12493 x -= 1;
12494 break;
12495
12496 case right:
12497 x += 1;
12498 break;
12499 }
12500 }
12501 }
12502 32 }
12503 else // hopping in or out (need to separate the cases...)
12504 {
12505
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 732 times.
732 if((diagonalMovement||NO_GRIDLOCK))
12506 {
12507 if(hopclk==1) //hopping out
12508 //>= 1 possible fix for getting stuck on land edges.
12509 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12510 {
12511 if(hopdir!=-1) dir=hopdir;
12512
12513 landswim=0;
12514
12515 if(dir==up)
12516 {
12517 herostep();
12518 herostep();
12519 int32_t sidestep=0;
12520
12521 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12522 sidestep=1;
12523 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12524 sidestep=2;
12525
12526 if(sidestep==1) x++;
12527 else if(sidestep==2) x--;
12528 else y--;
12529
12530 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12531 {
12532 hopclk=0;
12533 diveclk=0;
12534 action=none; FFCore.setHeroAction(none);
12535 hopdir=-1;
12536 }
12537 }
12538
12539 if(dir==down)
12540 {
12541 herostep();
12542 herostep();
12543 int32_t sidestep=0;
12544
12545 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12546 sidestep=1;
12547 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12548 sidestep=2;
12549
12550 if(sidestep==1) x++;
12551 else if(sidestep==2) x--;
12552 else y++;
12553
12554 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12555 {
12556 hopclk=0;
12557 diveclk=0;
12558 action=none; FFCore.setHeroAction(none);
12559 hopdir=-1;
12560 }
12561 }
12562
12563 if(dir==left)
12564 {
12565 herostep();
12566 herostep();
12567 int32_t sidestep=0;
12568
12569 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12570 sidestep=1;
12571 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12572 sidestep=2;
12573
12574 if(sidestep==1) y++;
12575 else if(sidestep==2) y--;
12576 else x--;
12577
12578 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12579 {
12580 hopclk=0;
12581 diveclk=0;
12582 action=none; FFCore.setHeroAction(none);
12583 hopdir=-1;
12584 }
12585 }
12586
12587 if(dir==right)
12588 {
12589 herostep();
12590 herostep();
12591 int32_t sidestep=0;
12592
12593 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12594 sidestep=1;
12595 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12596 sidestep=2;
12597
12598 if(sidestep==1) y++;
12599 else if(sidestep==2) y--;
12600 else x++;
12601
12602 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12603 {
12604 hopclk=0;
12605 diveclk=0;
12606 action=none; FFCore.setHeroAction(none);
12607 hopdir=-1;
12608 }
12609 }
12610 }
12611
12612 if(hopclk==2) //hopping in
12613 {
12614 landswim=0;
12615
12616 if(dir==up)
12617 {
12618 herostep();
12619 herostep();
12620 int32_t sidestep=0;
12621
12622 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12623 sidestep=1;
12624 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12625 sidestep=2;
12626
12627 if(sidestep==1) x++;
12628 else if(sidestep==2) x--;
12629 else y--;
12630
12631 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12632 {
12633 hopclk=0xFF;
12634 diveclk=0;
12635 SetSwim();
12636 }
12637 }
12638
12639 if(dir==down)
12640 {
12641 herostep();
12642 herostep();
12643 int32_t sidestep=0;
12644
12645 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12646 sidestep=1;
12647 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12648 sidestep=2;
12649
12650 if(sidestep==1) x++;
12651 else if(sidestep==2) x--;
12652 else y++;
12653
12654 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12655 {
12656 hopclk=0xFF;
12657 diveclk=0;
12658 SetSwim();
12659 if (!IsSideSwim()) reset_swordcharge();
12660 }
12661 }
12662
12663 if(dir==left)
12664 {
12665 herostep();
12666 herostep();
12667 int32_t sidestep=0;
12668
12669 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12670 sidestep=1;
12671 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12672 sidestep=2;
12673
12674 if(sidestep==1) y++;
12675 else if(sidestep==2) y--;
12676 else x--;
12677
12678 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12679 {
12680 hopclk=0xFF;
12681 diveclk=0;
12682 SetSwim();
12683 }
12684 }
12685
12686 if(dir==right)
12687 {
12688 herostep();
12689 herostep();
12690
12691 int32_t sidestep=0;
12692
12693 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12694 sidestep=1;
12695 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12696 sidestep=2;
12697
12698 if(sidestep==1) y++;
12699 else if(sidestep==2) y--;
12700 else x++;
12701
12702 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12703 {
12704 hopclk=0xFF;
12705 diveclk=0;
12706 SetSwim();
12707 }
12708 }
12709 }
12710
12711 }
12712 else
12713 {
12714
7/8
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 432 times.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 235 times.
✓ Branch 5 taken 65 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 396 times.
732 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12715 {
12716 65 action=none; FFCore.setHeroAction(none);
12717 65 hopclk = 0;
12718 65 diveclk = 0;
12719
12720
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 33 times.
65 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12721 {
12722 // hopped in
12723 33 SetSwim();
12724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (!IsSideSwim()) attackclk = charging = spins = 0;
12725 33 }
12726 65 }
12727 else
12728 {
12729 667 herostep();
12730 667 herostep();
12731
12732
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 39 times.
667 if(++hero_count>(16*hero_animation_speed))
12733 39 hero_count=0;
12734
12735 667 int32_t xofs2 = x.getInt()&15;
12736 667 int32_t yofs2 = y.getInt()&15;
12737 667 int32_t s = 1 + (frame&1);
12738
12739
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 198 times.
✓ Branch 4 taken 198 times.
667 switch(dir)
12740 {
12741 case up:
12742
3/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
40 if(yofs2<3 || yofs2>13) --y;
12743 28 else y-=s;
12744
12745 40 break;
12746
12747 case down:
12748
4/4
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 158 times.
231 if(yofs2<3 || yofs2>13) ++y;
12749 158 else y+=s;
12750
12751 231 break;
12752
12753 case left:
12754
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 141 times.
198 if(xofs2<3 || xofs2>13) --x;
12755 141 else x-=s;
12756
12757 198 break;
12758
12759 case right:
12760
4/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 135 times.
198 if(xofs2<3 || xofs2>13) ++x;
12761 135 else x+=s;
12762
12763 198 break;
12764 }
12765 }
12766 }
12767 }
12768 764 }
12769
12770 12573 void HeroClass::do_rafting()
12771 {
12772
12773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12573 times.
12573 if(toogam)
12774 {
12775 action=none; FFCore.setHeroAction(none);
12776 return;
12777 }
12778
12779 12573 FFCore.setHeroAction(rafting);
12780
12781 12573 do_lens();
12782
12783 12573 herostep();
12784
12785 //Calculate rafting speed
12786 12573 int32_t raft_item = current_item_id(itype_raft);
12787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12573 times.
12573 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12788 12573 raft_step = vbound(raft_step, -8, 5);
12789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12573 times.
12573 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12573 times.
12573 if(raft_step < 0) raft_step = 1;
12791 12573 int32_t step_inc = 1 << (raft_step - 1);
12792 // Fix position
12793
1/2
✓ Branch 0 taken 12573 times.
✗ Branch 1 not taken.
12573 if(raft_step > 1)
12794 {
12795 if(x.getInt() & (step_inc-1))
12796 {
12797 x = x.getInt() & ~(step_inc-1);
12798 }
12799 if(y.getInt() & (step_inc-1))
12800 {
12801 y = y.getInt() & ~(step_inc-1);
12802 }
12803 }
12804 // Inc clock, check if we need to move this frame
12805 12573 ++raftclk;
12806
2/4
✓ Branch 0 taken 12573 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12573 times.
12573 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12807
12808
4/4
✓ Branch 0 taken 6378 times.
✓ Branch 1 taken 6195 times.
✓ Branch 2 taken 5419 times.
✓ Branch 3 taken 959 times.
13527 if(!(x.getInt()&15) && !(y.getInt()&15))
12809 {
12810 // this sections handles switching to raft branches
12811
3/4
✓ Branch 0 taken 942 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 942 times.
959 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12812 {
12813
5/8
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12814 {
12815 3 dir = up;
12816 3 goto skip;
12817 }
12818
12819
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12820 {
12821 dir = down;
12822 goto skip;
12823 }
12824
12825
5/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12826 {
12827 1 dir = left;
12828 1 goto skip;
12829 }
12830
12831
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12832 {
12833 1 dir = right;
12834 1 goto skip;
12835 }
12836 12 }
12837
2/4
✓ Branch 0 taken 942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 942 times.
942 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
12838 {
12839 if(dir == left) dir = right;
12840 else if(dir == right) dir = left;
12841 else if(dir == up) dir = down;
12842 else if(dir == down) dir = up;
12843 }
12844
12845
12846
3/4
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 796 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 158 times.
954 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
12847 {
12848
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 65 times.
158 if(dir<left) //going up or down
12849 {
12850
3/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
93 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12851 3 dir=right;
12852
3/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
90 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12853 12 dir=left;
12854
4/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 7 times.
78 else if(y>0 && y<160)
12855 {
12856 64 action=none; FFCore.setHeroAction(none);
12857 64 x = x.getInt();
12858 64 y = y.getInt();
12859 64 }
12860 93 }
12861 else //going left or right
12862 {
12863
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
65 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12864 14 dir=down;
12865
3/4
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
51 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12866 2 dir=up;
12867
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
49 else if(x>0 && x<240)
12868 {
12869 49 action=none; FFCore.setHeroAction(none);
12870 49 x = x.getInt();
12871 49 y = y.getInt();
12872 49 }
12873 }
12874 158 }
12875 954 }
12876
12877 skip:
12878
12879
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2961 times.
✓ Branch 2 taken 2921 times.
✓ Branch 3 taken 2692 times.
✓ Branch 4 taken 3999 times.
12573 switch(dir)
12880 {
12881 case up:
12882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2961 times.
2961 if(x.getInt()&15)
12883 {
12884 if(x.getInt()&8)
12885 x++;
12886 else x--;
12887 }
12888 2961 else y -= step_inc;
12889
12890 2961 break;
12891
12892 case down:
12893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2921 times.
2921 if(x.getInt()&15)
12894 {
12895 if(x.getInt()&8)
12896 x++;
12897 else x--;
12898 }
12899 2921 else y += step_inc;
12900
12901 2921 break;
12902
12903 case left:
12904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2692 times.
2692 if(y.getInt()&15)
12905 {
12906 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12907 {
12908 if ((y.getInt() % 16) < 4) y--;
12909 else y++;
12910 }
12911 else
12912 {
12913 if(y.getInt()&8)
12914 y++;
12915 else y--;
12916 }
12917 }
12918 2692 else x -= step_inc;
12919
12920 2692 break;
12921
12922 case right:
12923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3999 times.
3999 if(y.getInt()&15)
12924 {
12925 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12926 {
12927 if ((y.getInt() % 16) <= 4) y--;
12928 else y++;
12929 }
12930 else
12931 {
12932 if(y.getInt()&8)
12933 y++;
12934 else y--;
12935 }
12936 }
12937 3999 else x += step_inc;
12938
12939 3999 break;
12940 }
12941 12573 }
12942
12943 bool HeroClass::try_hover()
12944 {
12945 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
12946 {
12947 int32_t itemid = current_item_id(itype_hoverboots);
12948 if(hoverclk < 0)
12949 hoverclk = -hoverclk;
12950 else
12951 {
12952 fall = fakefall = jumping = 0;
12953 if(itemsbuf[itemid].misc1)
12954 hoverclk = itemsbuf[itemid].misc1;
12955 else
12956 {
12957 hoverclk = 1;
12958 hoverflags |= HOV_INF;
12959 }
12960
12961
12962 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
12963 }
12964 if(itemsbuf[itemid].wpn)
12965 decorations.add(new dHover(x, y, dHOVER, 0));
12966 return true;
12967 }
12968 return false;
12969 }
12970
12971 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
12972 //Returns '-1' if not being pulled
12973 //Returns '-2' if should be falling in
12974 9289822 int32_t HeroClass::check_pitslide(bool ignore_hover)
12975 {
12976 //Pitfall todo -Emily
12977 //Iron boots; can't fight slipping, 2px/frame
12978 //Scripted variables to read pull dir/clk (clk only for non-hero)
12979 //Implement falling for all sprite types (npc AI)
12980 // Fall/slipping tiles for enemies
12981 // Fall/slipping SFX for enemies
12982 // Fall SFX for items/weapons
12983 // Weapons/Misc sprite shared for falling items/weapons
12984 //Maybe slip SFX for Hero?
12985 // Weapons/Misc sprite override for falling sprite?
12986 //Update std.zh with relevant new stuff
12987
2/2
✓ Branch 0 taken 246104 times.
✓ Branch 1 taken 9043718 times.
9289822 if(can_pitfall(ignore_hover))
12988 {
12989
2/2
✓ Branch 0 taken 18580 times.
✓ Branch 1 taken 9025138 times.
9043718 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
12990 9043718 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
12991 9043718 int32_t ispitbl = getpitfall(x,y+15);
12992 9043718 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
12993 9043718 int32_t ispitbr = getpitfall(x+15,y+15);
12994 9043718 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
12995 9043718 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
12996 9043718 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
12997 9043718 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
12998 9043718 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
12999 9043718 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13000 9043718 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13001 9043718 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13002 static const int32_t flag_pit_irresistable = (1<<24);
13003
1/5
✓ Branch 0 taken 9043718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
9043718 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13004 {
13005 case 4: return -2; //Fully over pit; fall in
13006 case 3:
13007 {
13008 if(ispitul && ispitur && ispitbl) //UL_3
13009 {
13010 if(ispitul_50)
13011 {
13012 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13013 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13014 }
13015 }
13016 else if(ispitul && ispitur && ispitbr) //UR_3
13017 {
13018 if(ispitur_50)
13019 {
13020 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13021 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13022 }
13023 }
13024 else if(ispitul && ispitbl && ispitbr) //BL_3
13025 {
13026 if(ispitbl_50)
13027 {
13028 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13029 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13030 }
13031 }
13032 else if(ispitbl && ispitur && ispitbr) //BR_3
13033 {
13034 if(ispitbr_50)
13035 {
13036 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13037 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13038 }
13039 }
13040 break;
13041 }
13042 case 2:
13043 {
13044 if(ispitul && ispitur) //Up
13045 {
13046 if(DrunkDown())
13047 {
13048 if(ispitul_75 && ispitur_75) //Straight up
13049 {
13050 return up | flag_pit_irresistable | (ispitul << 8);
13051 }
13052 else if(ispitul_75)
13053 {
13054 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13055 }
13056 else if(ispitur_75)
13057 {
13058 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13059 }
13060 else return -1;
13061 }
13062 else
13063 {
13064 if(ispitul_50 && ispitur_50) //Straight up
13065 {
13066 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13067 }
13068 else if(ispitul_50)
13069 {
13070 if(DrunkRight() && !ispitul_75) return -1;
13071 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13072 }
13073 else if(ispitur_50)
13074 {
13075 if(DrunkLeft() && !ispitur_75) return -1;
13076 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13077 }
13078 }
13079 }
13080 else if(ispitbl && ispitbr) //Down
13081 {
13082 if(DrunkUp())
13083 {
13084 if(ispitbl_75 && ispitbr_75) //Straight down
13085 {
13086 return down | flag_pit_irresistable | (ispitbl << 8);
13087 }
13088 else if(ispitbl_75)
13089 {
13090 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13091 }
13092 else if(ispitbr_75)
13093 {
13094 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13095 }
13096 else return -1;
13097 }
13098 else
13099 {
13100 if(ispitbl_50 && ispitbr_50) //Straight down
13101 {
13102 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13103 }
13104 else if(ispitbl_50)
13105 {
13106 if(DrunkRight() && !ispitbl_75) return -1;
13107 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13108 }
13109 else if(ispitbr_50)
13110 {
13111 if(DrunkLeft() && !ispitbr_75) return -1;
13112 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13113 }
13114 }
13115 }
13116 else if(ispitbl && ispitul) //Left
13117 {
13118 if(DrunkRight())
13119 {
13120 if(ispitul_75 && ispitbl_75) //Straight left
13121 {
13122 return left | flag_pit_irresistable | (ispitul << 8);
13123 }
13124 else if(ispitul_75)
13125 {
13126 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13127 }
13128 else if(ispitbl_75)
13129 {
13130 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13131 }
13132 else return -1;
13133 }
13134 else
13135 {
13136 if(ispitul_50 && ispitbl_50) //Straight left
13137 {
13138 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13139 }
13140 else if(ispitul_50)
13141 {
13142 if(DrunkDown() && !ispitul_75) return -1;
13143 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13144 }
13145 else if(ispitbl_50)
13146 {
13147 if(DrunkUp() && !ispitbl_75) return -1;
13148 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13149 }
13150 }
13151 }
13152 else if(ispitbr && ispitur) //Right
13153 {
13154 if(DrunkLeft())
13155 {
13156 if(ispitur_75 && ispitbr_75) //Straight right
13157 {
13158 return right | flag_pit_irresistable | (ispitur << 8);
13159 }
13160 else if(ispitur_75)
13161 {
13162 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13163 }
13164 else if(ispitbr_75)
13165 {
13166 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13167 }
13168 else return -1;
13169 }
13170 else
13171 {
13172 if(ispitur_50 && ispitbr_50) //Straight right
13173 {
13174 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13175 }
13176 else if(ispitur_50)
13177 {
13178 if(DrunkDown() && !ispitur_75) return -1;
13179 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13180 }
13181 else if(ispitbr_50)
13182 {
13183 if(DrunkUp() && !ispitbr_75) return -1;
13184 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13185 }
13186 }
13187 }
13188 break;
13189 }
13190 case 1:
13191 {
13192 if(ispitul && ispitul_50) //UL_1
13193 {
13194 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13195 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13196 }
13197 if(ispitur && ispitur_50) //UR_1
13198 {
13199 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13200 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13201 }
13202 if(ispitbl && ispitbl_50) //BL_1
13203 {
13204 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13205 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13206 }
13207 if(ispitbr && ispitbr_50) //BR_1
13208 {
13209 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13210 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13211 }
13212 break;
13213 }
13214 }
13215 9043718 }
13216 9289822 return -1;
13217 9289822 }
13218
13219 1938902 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13220 {
13221 1938902 pitfall();
13222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1938902 times.
1938902 if(fallclk) return true;
13223 1938902 int32_t val = check_pitslide();
13224 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1938902 times.
1938902 if(val == -1)
13226 {
13227 1938902 pit_pulldir = -1;
13228 1938902 pit_pullclk = 0;
13229 1938902 return false;
13230 }
13231 int32_t dir = val&0xFF;
13232 int32_t cmbid = (val&0xFFFF00)>>8;
13233 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13234 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13235 {
13236 pit_pulldir = -1;
13237 pit_pullclk = 0;
13238 return false;
13239 }
13240 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13241 {
13242 pit_pulldir = -1;
13243 pit_pullclk = 0;
13244 return false;
13245 }
13246 pit_pulldir = dir;
13247 int32_t step = 1;
13248 if(sensitivity == 0)
13249 {
13250 step = 2;
13251 sensitivity = 1;
13252 }
13253 if(pit_pullclk++ % sensitivity) //No pull this frame
13254 return (val&0x100);
13255 for(; step > 0 && !fallclk; --step)
13256 {
13257 switch(dir)
13258 {
13259 case l_up: case l_down: case left:
13260 --x; break;
13261 case r_up: case r_down: case right:
13262 ++x; break;
13263 }
13264 switch(dir)
13265 {
13266 case l_up: case r_up: case up:
13267 --y; break;
13268 case l_down: case r_down: case down:
13269 ++y; break;
13270 }
13271 pitfall();
13272 }
13273 return fallclk || (val&0x100);
13274 1938902 }
13275
13276 1938902 void HeroClass::pitfall()
13277 {
13278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1938902 times.
1938902 if(fallclk)
13279 {
13280 drop_liftwpn();
13281 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13282 //Handle falling
13283 if(!--fallclk)
13284 {
13285 int32_t dmg = game->get_hp_per_heart()/4;
13286 bool dmg_perc = false;
13287 bool warp = false;
13288
13289 action=none; FFCore.setHeroAction(none);
13290 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13291 if(cmb)
13292 {
13293 dmg = cmb->attributes[0]/10000L;
13294 dmg_perc = cmb->usrflags&cflag3;
13295 warp = cmb->usrflags&cflag1;
13296 }
13297 if(dmg) //Damage
13298 {
13299 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13300 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13301 }
13302 if(warp) //Warp
13303 {
13304 sdir = dir;
13305 if(cmb->usrflags&cflag2) //Direct Warp
13306 {
13307 didpit=true;
13308 pitx=x;
13309 pity=y;
13310 }
13311 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13312 }
13313 else //Reset to screen entry
13314 {
13315 go_respawn_point();
13316 }
13317 }
13318 }
13319
2/2
✓ Branch 0 taken 40963 times.
✓ Branch 1 taken 1897939 times.
1938902 else if(can_pitfall())
13320 {
13321 1897939 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13322 1897939 bool ispitbl = ispitfall(x,y+15);
13323 1897939 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13324 1897939 bool ispitbr = ispitfall(x+15,y+15);
13325 1897939 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13326
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1897939 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1897939 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13327 {
13328 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13329 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13330 fallclk = PITFALL_FALL_FRAMES;
13331 fallCombo = pitctr;
13332 action=falling; FFCore.setHeroAction(falling);
13333 spins = 0;
13334 charging = 0;
13335 drop_liftwpn();
13336 }
13337 1897939 }
13338 1938902 }
13339
13340 2344795 void HeroClass::movehero()
13341 {
13342
2/4
✓ Branch 0 taken 2344795 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2344795 times.
2344795 if(lstunclock || is_conveyor_stunned) return;
13343 2344795 int32_t xoff=x.getInt()&7;
13344 2344795 int32_t yoff=y.getInt()&7;
13345
2/2
✓ Branch 0 taken 2335485 times.
✓ Branch 1 taken 9310 times.
2344795 if(NO_GRIDLOCK)
13346 {
13347 9310 xoff = 0;
13348 9310 yoff = 0;
13349 9310 }
13350 2344795 int32_t push=pushing;
13351 2344795 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13352 2344795 pushing=0;
13353 2344795 zfix temp_step(hero_newstep);
13354 2344795 zfix temp_x(x);
13355 2344795 zfix temp_y(y);
13356
13357 2344795 int32_t flippers_id = current_item_id(itype_flippers);
13358
2/2
✓ Branch 0 taken 2401 times.
✓ Branch 1 taken 2342394 times.
2344795 if(diveclk>0)
13359 {
13360
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2401 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13361 2401 --diveclk;
13362
4/8
✓ Branch 0 taken 1567 times.
✓ Branch 1 taken 834 times.
✓ Branch 2 taken 1567 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1567 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2401 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
13363 {
13364 diveclk = itemsbuf[flippers_id].misc2;
13365 }
13366 2401 }
13367
4/4
✓ Branch 0 taken 8700 times.
✓ Branch 1 taken 2333694 times.
✓ Branch 2 taken 8665 times.
✓ Branch 3 taken 35 times.
2342394 else if(action == swimming && DrunkrAbtn())
13368 {
13369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13370 35 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13371
13372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(global_diving==screen_diving)
13373
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13374 35 }
13375
13376
2/2
✓ Branch 0 taken 2332222 times.
✓ Branch 1 taken 12573 times.
2344795 if(action==rafting)
13377 {
13378 12573 do_rafting();
13379
13380
2/2
✓ Branch 0 taken 12460 times.
✓ Branch 1 taken 113 times.
12573 if(action==rafting)
13381 {
13382 12460 return;
13383 }
13384
13385
13386 113 set_respawn_point();
13387 113 trySideviewLadder();
13388 113 }
13389
13390 2332335 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13391 2332335 int32_t btnwpn = -1;
13392
13393 //&0xFFF removes the "bow & arrows" bitmask
13394 //The Quick Sword is allowed to interrupt attacks.
13395
4/4
✓ Branch 0 taken 2302403 times.
✓ Branch 1 taken 29932 times.
✓ Branch 2 taken 1676239 times.
✓ Branch 3 taken 626164 times.
2332335 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13396
7/8
✓ Branch 0 taken 1940253 times.
✓ Branch 1 taken 392082 times.
✓ Branch 2 taken 1937736 times.
✓ Branch 3 taken 2517 times.
✓ Branch 4 taken 89062 times.
✓ Branch 5 taken 305537 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 394599 times.
2332335 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13397 {
13398
2/2
✓ Branch 0 taken 6354 times.
✓ Branch 1 taken 1931382 times.
1937736 if(DrunkrBbtn())
13399 {
13400 6354 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13401 6354 dowpn = Bwpn&0xFFF;
13402 6354 directWpn = directItemB;
13403 6354 }
13404
2/2
✓ Branch 0 taken 22874 times.
✓ Branch 1 taken 1908508 times.
1931382 else if(DrunkrAbtn())
13405 {
13406 22874 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13407 22874 dowpn = Awpn&0xFFF;
13408 22874 directWpn = directItemA;
13409 22874 }
13410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1908508 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1908508 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13411 {
13412 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13413 dowpn = Xwpn&0xFFF;
13414 directWpn = directItemX;
13415 }
13416
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1908508 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1908508 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13417 {
13418 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13419 dowpn = Ywpn&0xFFF;
13420 directWpn = directItemY;
13421 }
13422
13423
1/2
✓ Branch 0 taken 1937736 times.
✗ Branch 1 not taken.
1937736 if(directWpn > 255) directWpn = 0;
13424
13425 // The Quick Sword only allows repeated sword or wand swings.
13426
3/8
✓ Branch 0 taken 1937736 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1937736 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1937736 times.
1937736 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13427 btnwpn=-1;
13428 1937736 }
13429
13430
1/2
✓ Branch 0 taken 2332335 times.
✗ Branch 1 not taken.
2332335 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13431
10/12
✓ Branch 0 taken 2271277 times.
✓ Branch 1 taken 61058 times.
✓ Branch 2 taken 2250664 times.
✓ Branch 3 taken 20613 times.
✓ Branch 4 taken 2250664 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2222789 times.
✓ Branch 7 taken 27875 times.
✓ Branch 8 taken 22599 times.
✓ Branch 9 taken 2200190 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 22599 times.
2332335 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13432 {
13433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22599 times.
22599 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13434
2/6
✓ Branch 0 taken 22599 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22599 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22599 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13435 {
13436
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22599 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13437 {
13438 paymagiccost(attackid,true);
13439 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13440 }
13441 22599 SetAttack();
13442 22599 attack=wSword;
13443
13444 22599 attackclk=0;
13445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22599 times.
22599 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13446
13447
2/10
✓ Branch 0 taken 22599 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22599 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
22599 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13448 {
13449 if(!checkmagiccost(dowpn))
13450 {
13451 if(QMisc.miscsfx[sfxERROR])
13452 sfx(QMisc.miscsfx[sfxERROR]);
13453 }
13454 else
13455 {
13456 //clear the item script stack for a new script
13457
13458 ri = &(itemScriptData[dowpn]);
13459 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13460 ri->Clear();
13461 //itemScriptData[(dowpn & 0xFFF)].Clear();
13462 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13463 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13464 item_doscript[dowpn] = 1;
13465 itemscriptInitialised[dowpn] = 0;
13466 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13467 did_scripta=true;
13468 }
13469 }
13470 22599 }
13471 else
13472 {
13473 if(QMisc.miscsfx[sfxERROR])
13474 sfx(QMisc.miscsfx[sfxERROR]);
13475 }
13476 22599 }
13477 else
13478 {
13479 2309736 did_scripta=false;
13480 }
13481
13482
7/10
✓ Branch 0 taken 2321234 times.
✓ Branch 1 taken 11101 times.
✓ Branch 2 taken 2321234 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2321234 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2321234 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 304 times.
✓ Branch 9 taken 2320930 times.
2332335 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13483 {
13484
4/4
✓ Branch 0 taken 393215 times.
✓ Branch 1 taken 1927715 times.
✓ Branch 2 taken 393213 times.
✓ Branch 3 taken 2 times.
2320930 if(DrunkUp() && canSideviewLadder())
13485 {
13486 2 setOnSideviewLadder(true);
13487 2 }
13488
4/4
✓ Branch 0 taken 318579 times.
✓ Branch 1 taken 2002349 times.
✓ Branch 2 taken 318574 times.
✓ Branch 3 taken 5 times.
2320928 else if(DrunkDown() && canSideviewLadder(true))
13489 {
13490 5 y+=1;
13491 5 setOnSideviewLadder(true);
13492 5 }
13493 2320930 }
13494
13495 2332335 int32_t wx=x;
13496 2332335 int32_t wy=y;
13497
5/6
✓ Branch 0 taken 1761275 times.
✓ Branch 1 taken 571060 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 2332024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 311 times.
2332335 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13498 {
13499
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
311 if((xoff==0)||diagonalMovement)
13500 {
13501
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 109 times.
311 if(DrunkUp()) dir=up;
13502
2/2
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 160 times.
311 if(DrunkDown()) dir=down;
13503 311 }
13504
13505
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
311 if((yoff==0)||diagonalMovement)
13506 {
13507
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 43 times.
311 if(DrunkLeft()) dir=left;
13508
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 6 times.
311 if(DrunkRight()) dir=right;
13509 311 }
13510 311 }
13511
13512
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 554924 times.
✓ Branch 2 taken 466626 times.
✓ Branch 3 taken 640361 times.
✓ Branch 4 taken 670424 times.
2332335 switch(dir)
13513 {
13514 case up:
13515 554924 wy-=16;
13516 554924 break;
13517
13518 case down:
13519 466626 wy+=16;
13520 466626 break;
13521
13522 case left:
13523 640361 wx-=16;
13524 640361 break;
13525
13526 case right:
13527 670424 wx+=16;
13528 670424 break;
13529 }
13530
13531 2332335 do_lens();
13532
13533 2332335 WalkflagInfo info;
13534
13535 2332335 bool no_jinx = true;
13536
7/8
✓ Branch 0 taken 2271277 times.
✓ Branch 1 taken 61058 times.
✓ Branch 2 taken 6338 times.
✓ Branch 3 taken 2264939 times.
✓ Branch 4 taken 6338 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 6322 times.
2332335 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13537 {
13538 6322 bool paidmagic = false;
13539
4/8
✓ Branch 0 taken 5711 times.
✓ Branch 1 taken 611 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 611 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 611 times.
6322 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13540 {
13541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13542 611 no_jinx = checkitem_jinx(attackid);
13543
3/8
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 611 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 611 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
611 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13544 {
13545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
611 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13546 paymagiccost(attackid,true);
13547 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13548 }
13549 611 SetAttack();
13550 611 attack=wWand;
13551 611 attackclk=0;
13552 611 }
13553 else
13554 {
13555 if(QMisc.miscsfx[sfxERROR])
13556 sfx(QMisc.miscsfx[sfxERROR]);
13557 }
13558 611 }
13559
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5711 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5711 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13560 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13561 {
13562 no_jinx = checkitem_jinx(dowpn);
13563 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13564 {
13565 if(QMisc.miscsfx[sfxERROR])
13566 sfx(QMisc.miscsfx[sfxERROR]);
13567 }
13568 else
13569 {
13570 paymagiccost(dowpn);
13571 paidmagic = true;
13572 SetAttack();
13573 attack=wHammer;
13574 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13575 attackclk=0;
13576 }
13577 }
13578
4/6
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 5157 times.
✓ Branch 2 taken 554 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 554 times.
6265 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13579
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 554 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
554 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13580 {
13581 //checkbunny handled where magic cost is paid
13582
1/2
✓ Branch 0 taken 554 times.
✗ Branch 1 not taken.
554 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13583 554 no_jinx = checkitem_jinx(attackid);
13584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 554 times.
554 if(no_jinx)
13585 {
13586 554 SetAttack();
13587 554 attack=wFire;
13588 554 attackclk=0;
13589 554 }
13590 554 }
13591
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5157 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13592 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13593 {
13594 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13595 no_jinx = checkitem_jinx(attackid);
13596 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13597 {
13598 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13599 paymagiccost(attackid,true);
13600 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13601 }
13602 SetAttack();
13603 attack=wCByrna;
13604 attackclk=0;
13605 }
13606 else
13607 {
13608 if(QMisc.miscsfx[sfxERROR])
13609 sfx(QMisc.miscsfx[sfxERROR]);
13610 }
13611 }
13612
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5157 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13613 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13614 {
13615 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13616 no_jinx = checkitem_jinx(attackid);
13617 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13618 {
13619 paymagiccost(attackid);
13620 SetAttack();
13621 attack = wBugNet;
13622 attackclk = 0;
13623 sfx(itemsbuf[attackid].usesound);
13624 }
13625 else
13626 {
13627 if(QMisc.miscsfx[sfxERROR])
13628 sfx(QMisc.miscsfx[sfxERROR]);
13629 }
13630 }
13631 else
13632 {
13633
1/2
✓ Branch 0 taken 5157 times.
✗ Branch 1 not taken.
5157 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13634 5157 no_jinx = checkitem_jinx(itmid);
13635
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5143 times.
5157 if(no_jinx)
13636 {
13637 5143 paidmagic = startwpn(itmid);
13638
13639
2/2
✓ Branch 0 taken 4802 times.
✓ Branch 1 taken 341 times.
5143 if(paidmagic)
13640 {
13641
5/10
✓ Branch 0 taken 4802 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4802 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4802 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4802 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 4802 times.
4802 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13642 {
13643 ;
13644 }
13645 else
13646 {
13647 4802 SetAttack();
13648 4802 attackclk=0;
13649 4802 attack=none;
13650
13651
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 4159 times.
4802 if(btnwpn==itype_brang)
13652 {
13653 4159 attack=wBrang;
13654 4159 }
13655 }
13656 4802 }
13657 else
13658 {
13659 // Weapon not started: directWpn should be reset to prev. value.
13660 341 directWpn = olddirectwpn;
13661 }
13662 5143 }
13663 }
13664
13665
4/12
✓ Branch 0 taken 6322 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6308 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
6322 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13666 {
13667 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13668 {
13669 if(QMisc.miscsfx[sfxERROR])
13670 sfx(QMisc.miscsfx[sfxERROR]);
13671 }
13672 else
13673 {
13674 // Only charge for magic if item's magic cost wasn't already charged
13675 // for the item's main use.
13676 if(!paidmagic && attack!=wWand)
13677 paymagiccost(dowpn);
13678 //clear the item script stack for a new script
13679 //itemScriptData[(dowpn & 0xFFF)].Clear();
13680 ri = &(itemScriptData[dowpn]);
13681 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13682 ri->Clear();
13683 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13684 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13685 item_doscript[dowpn] = 1;
13686 itemscriptInitialised[dowpn] = 0;
13687 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13688 did_scriptb=true;
13689 }
13690 }
13691
13692
7/12
✓ Branch 0 taken 6308 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6308 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6308 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6308 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 6308 times.
6322 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13693 {
13694 return;
13695 }
13696
2/2
✓ Branch 0 taken 6308 times.
✓ Branch 1 taken 14 times.
6322 if(!no_jinx)
13697 14 did_scriptb = false;
13698 6322 }
13699 else
13700 {
13701 2326013 did_scriptb=false;
13702 }
13703
13704
5/6
✓ Branch 0 taken 1940253 times.
✓ Branch 1 taken 392082 times.
✓ Branch 2 taken 1909170 times.
✓ Branch 3 taken 31083 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1909170 times.
2332335 if(attackclk || action==attacking || action==sideswimattacking)
13705 {
13706
13707
4/8
✓ Branch 0 taken 31083 times.
✓ Branch 1 taken 392082 times.
✓ Branch 2 taken 31083 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 31083 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
423165 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13708 {
13709 if((xoff==0)||diagonalMovement)
13710 {
13711 if(DrunkUp()) dir=up;
13712 if(DrunkDown()) dir=down;
13713 }
13714
13715 if((yoff==0)||diagonalMovement)
13716 {
13717 if(DrunkLeft()) dir=left;
13718 if(DrunkRight()) dir=right;
13719 }
13720 }
13721
13722 423165 bool attacked = doattack();
13723
13724 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
13725
9/12
✓ Branch 0 taken 421753 times.
✓ Branch 1 taken 1412 times.
✓ Branch 2 taken 298914 times.
✓ Branch 3 taken 122839 times.
✓ Branch 4 taken 55716 times.
✓ Branch 5 taken 243198 times.
✓ Branch 6 taken 55716 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 55716 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 55716 times.
423165 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
13726 {
13727
3/4
✓ Branch 0 taken 23849 times.
✓ Branch 1 taken 31867 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23849 times.
55716 if((xoff==0)||diagonalMovement)
13728 {
13729
2/2
✓ Branch 0 taken 29285 times.
✓ Branch 1 taken 2582 times.
31867 if(DrunkUp()) dir=up;
13730
13731
2/2
✓ Branch 0 taken 28982 times.
✓ Branch 1 taken 2885 times.
31867 if(DrunkDown()) dir=down;
13732 31867 }
13733
13734
3/4
✓ Branch 0 taken 16728 times.
✓ Branch 1 taken 38988 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16728 times.
55716 if((yoff==0)||diagonalMovement)
13735 {
13736
2/2
✓ Branch 0 taken 35308 times.
✓ Branch 1 taken 3680 times.
38988 if(DrunkLeft()) dir=left;
13737
13738
2/2
✓ Branch 0 taken 35450 times.
✓ Branch 1 taken 3538 times.
38988 if(DrunkRight()) dir=right;
13739 38988 }
13740 55716 }
13741
13742
6/10
✓ Branch 0 taken 393433 times.
✓ Branch 1 taken 29732 times.
✓ Branch 2 taken 393433 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 393433 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 393433 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 393433 times.
423165 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
13743 {
13744 393433 return;
13745 }
13746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29732 times.
29732 else if(!(attacked))
13747 {
13748 // Spin attack - change direction
13749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29732 times.
29732 if(spins>1)
13750 {
13751 spins--;
13752
13753 if(spins%5==0)
13754 sfx(itemsbuf[current_item_id(spins >5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
13755
13756 attackclk=1;
13757
13758 switch(dir)
13759 {
13760 case up:
13761 dir=left;
13762 break;
13763
13764 case right:
13765 dir=up;
13766 break;
13767
13768 case down:
13769 dir=right;
13770 break;
13771
13772 case left:
13773 dir=down;
13774 break;
13775 }
13776
13777 return;
13778 }
13779 else
13780 {
13781 29732 spins=0;
13782 }
13783
13784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29732 times.
29732 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
13785 29732 else {action=none; FFCore.setHeroAction(none);}
13786 29732 attackclk=0;
13787 29732 charging=0;
13788 29732 }
13789 29732 }
13790
13791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1938902 times.
1938902 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
13792 return;
13793
13794
2/2
✓ Branch 0 taken 609365 times.
✓ Branch 1 taken 1329537 times.
1938902 if(action==walking) //still walking
13795 {
13796
9/10
✓ Branch 0 taken 1003172 times.
✓ Branch 1 taken 326365 times.
✓ Branch 2 taken 751198 times.
✓ Branch 3 taken 251974 times.
✓ Branch 4 taken 394957 times.
✓ Branch 5 taken 356241 times.
✓ Branch 6 taken 14950 times.
✓ Branch 7 taken 380007 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14950 times.
1329537 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
13797 {
13798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14950 times.
14950 if(attackclk>0) SetAttack();
13799 14950 else {action = none; FFCore.setHeroAction(none);}
13800 14950 hero_count=-1;
13801 14950 return;
13802 }
13803
13804 1314587 autostep=false;
13805
13806
3/4
✓ Branch 0 taken 1309483 times.
✓ Branch 1 taken 5104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1309483 times.
1314587 if(!(diagonalMovement || NO_GRIDLOCK))
13807 {
13808
2/4
✓ Branch 0 taken 1309483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1309483 times.
1309483 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
13809 {
13810 if(dir==up&&yoff)
13811 {
13812 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
13813 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
13814 execute(info);
13815
13816 if(!info.isUnwalkable())
13817 {
13818 move(up);
13819 }
13820 else
13821 {
13822 action=none; FFCore.setHeroAction(none);
13823 }
13824
13825 return;
13826 }
13827
13828 if(dir==down&&yoff)
13829 {
13830 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
13831 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
13832 execute(info);
13833
13834 if(!info.isUnwalkable())
13835 {
13836 move(down);
13837 }
13838 else
13839 {
13840 action=none; FFCore.setHeroAction(none);
13841 }
13842
13843 return;
13844 }
13845
13846 if(dir==left&&xoff)
13847 {
13848 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
13849 execute(info);
13850
13851 if(!info.isUnwalkable())
13852 {
13853 move(left);
13854 }
13855 else
13856 {
13857 action=none; FFCore.setHeroAction(none);
13858 }
13859
13860 return;
13861 }
13862
13863 if(dir==right&&xoff)
13864 {
13865 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
13866 execute(info);
13867
13868 if(!info.isUnwalkable())
13869 {
13870 move(right);
13871 }
13872 else
13873 {
13874 action=none; FFCore.setHeroAction(none);
13875 }
13876
13877 return;
13878 }
13879 }
13880 else
13881 {
13882
4/4
✓ Branch 0 taken 311706 times.
✓ Branch 1 taken 997777 times.
✓ Branch 2 taken 51097 times.
✓ Branch 3 taken 260609 times.
1309483 if(dir==up&&yoff)
13883 {
13884 260609 while(true)
13885 {
13886 260609 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
13887 260609 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
13888 260609 execute(info);
13889
13890
2/2
✓ Branch 0 taken 839 times.
✓ Branch 1 taken 259770 times.
260609 if(!info.isUnwalkable())
13891 {
13892 259770 hero_newstep = temp_step;
13893 259770 x = temp_x;
13894 259770 y = temp_y;
13895 259770 move(up);
13896 259770 return;
13897 }
13898 //Could not move, try moving less
13899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 839 times.
839 if(temp_y != int32_t(temp_y))
13900 {
13901 temp_y = floor((double)temp_y);
13902 continue;
13903 }
13904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 839 times.
839 else if(temp_step > 1)
13905 {
13906 if(temp_step != int32_t(temp_step)) //floor
13907 temp_step = floor((double)temp_step);
13908 else --temp_step;
13909 continue;
13910 }
13911 else //Can't move less, stop moving
13912 {
13913 839 action=none; FFCore.setHeroAction(none);
13914 }
13915 839 return;
13916 }
13917 }
13918
13919
4/4
✓ Branch 0 taken 244199 times.
✓ Branch 1 taken 804675 times.
✓ Branch 2 taken 40409 times.
✓ Branch 3 taken 203790 times.
1048874 if(dir==down&&yoff)
13920 {
13921 203790 while(true)
13922 {
13923 203793 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
13924 203793 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
13925 203793 execute(info);
13926
13927
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 203133 times.
203793 if(!info.isUnwalkable())
13928 {
13929 203133 hero_newstep = temp_step;
13930 203133 x = temp_x;
13931 203133 y = temp_y;
13932 203133 move(down);
13933 203133 return;
13934 }
13935 //Could not move, try moving less
13936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 660 times.
660 if(temp_y != int32_t(temp_y))
13937 {
13938 temp_y = floor((double)temp_y);
13939 continue;
13940 }
13941
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 657 times.
660 else if(temp_step > 1)
13942 {
13943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(temp_step != int32_t(temp_step)) //floor
13944 3 temp_step = floor((double)temp_step);
13945 else --temp_step;
13946 3 continue;
13947 }
13948 else //Can't move less, stop moving
13949 {
13950 657 action=none; FFCore.setHeroAction(none);
13951 }
13952 657 return;
13953 }
13954 }
13955
13956
4/4
✓ Branch 0 taken 365470 times.
✓ Branch 1 taken 479614 times.
✓ Branch 2 taken 61403 times.
✓ Branch 3 taken 304067 times.
845084 if(dir==left&&xoff)
13957 {
13958 304067 while(true)
13959 {
13960 304067 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
13961 304067 execute(info);
13962
13963
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 303495 times.
304067 if(!info.isUnwalkable())
13964 {
13965 303495 hero_newstep = temp_step;
13966 303495 x = temp_x;
13967 303495 y = temp_y;
13968 303495 move(left);
13969 303495 return;
13970 }
13971 //Could not move, try moving less
13972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 if(temp_x != int32_t(temp_x))
13973 {
13974 temp_x = floor((double)temp_x);
13975 continue;
13976 }
13977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 else if(temp_step > 1)
13978 {
13979 if(temp_step != int32_t(temp_step)) //floor
13980 temp_step = floor((double)temp_step);
13981 else --temp_step;
13982 continue;
13983 }
13984 else //Can't move less, stop moving
13985 {
13986 572 action=none; FFCore.setHeroAction(none);
13987 }
13988 572 return;
13989 }
13990 }
13991
13992
4/4
✓ Branch 0 taken 388108 times.
✓ Branch 1 taken 152909 times.
✓ Branch 2 taken 64981 times.
✓ Branch 3 taken 323127 times.
541017 if(dir==right&&xoff)
13993 {
13994 323127 while(true)
13995 {
13996 323133 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
13997 323133 execute(info);
13998
13999
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 322716 times.
323133 if(!info.isUnwalkable())
14000 {
14001 322716 hero_newstep = temp_step;
14002 322716 x = temp_x;
14003 322716 y = temp_y;
14004 322716 move(right);
14005 322716 return;
14006 }
14007 //Could not move, try moving less
14008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
417 if(temp_x != int32_t(temp_x))
14009 {
14010 temp_x = floor((double)temp_x);
14011 continue;
14012 }
14013
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 411 times.
417 else if(temp_step > 1)
14014 {
14015
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
14016 6 temp_step = floor((double)temp_step);
14017 else --temp_step;
14018 6 continue;
14019 }
14020 else //Can't move less, stop moving
14021 {
14022 411 action=none; FFCore.setHeroAction(none);
14023 }
14024 411 return;
14025 }
14026 }
14027 }
14028 217890 }
14029
14030 222994 } // endif (action==walking)
14031
14032
14/24
✓ Branch 0 taken 821258 times.
✓ Branch 1 taken 11101 times.
✓ Branch 2 taken 821258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 821258 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 821258 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 821258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 821258 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 821258 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 821258 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 821258 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 821258 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 821258 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1430 times.
✓ Branch 23 taken 819828 times.
832359 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
14033 {
14034 819828 action=none; FFCore.setHeroAction(none);
14035 819828 }
14036
14037
2/2
✓ Branch 0 taken 9237 times.
✓ Branch 1 taken 823122 times.
832359 if(diagonalMovement)
14038 {
14039
5/5
✓ Branch 0 taken 2505 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 757 times.
✓ Branch 3 taken 2183 times.
✓ Branch 4 taken 3118 times.
9237 switch(holddir)
14040 {
14041 case up:
14042
2/2
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 24 times.
674 if(!Up())
14043 {
14044 24 holddir=-1;
14045 24 }
14046
14047 674 break;
14048
14049 case down:
14050
2/2
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 26 times.
757 if(!Down())
14051 {
14052 26 holddir=-1;
14053 26 }
14054
14055 757 break;
14056
14057 case left:
14058
2/2
✓ Branch 0 taken 2123 times.
✓ Branch 1 taken 60 times.
2183 if(!Left())
14059 {
14060 60 holddir=-1;
14061 60 }
14062
14063 2183 break;
14064
14065 case right:
14066
2/2
✓ Branch 0 taken 3042 times.
✓ Branch 1 taken 76 times.
3118 if(!Right())
14067 {
14068 76 holddir=-1;
14069 76 }
14070
14071 3118 break;
14072
14073 default:
14074 2505 break;
14075 } //end switch
14076
14077
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9237 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9237 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14078 {
14079 9237 walkable = false;
14080
6/6
✓ Branch 0 taken 989 times.
✓ Branch 1 taken 8248 times.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 650 times.
9237 if(DrunkUp()&&(holddir==-1||holddir==up))
14081 {
14082
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
674 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14083 {
14084 }
14085 else
14086 {
14087
4/10
✓ Branch 0 taken 674 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 674 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 674 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 674 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
674 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14088 {
14089 674 dir=up;
14090 674 }
14091
14092 674 holddir=up;
14093
14094
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 578 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
674 if(DrunkRight()&&shiftdir!=left)
14095 {
14096 96 shiftdir=right;
14097
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
96 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14098
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
96 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14099 96 }
14100
3/4
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 228 times.
578 else if(DrunkLeft()&&shiftdir!=right)
14101 {
14102 228 shiftdir=left;
14103
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14104
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
228 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14105 228 }
14106 else
14107 {
14108 350 shiftdir=-1;
14109 }
14110
14111 //walkable if Ladder can be placed or is already placed vertically
14112
9/20
✓ Branch 0 taken 377 times.
✓ Branch 1 taken 297 times.
✓ Branch 2 taken 377 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 272 times.
✓ Branch 13 taken 105 times.
✓ Branch 14 taken 272 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 272 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 272 times.
674 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14113 {
14114 272 walkable=false;
14115 272 }
14116 else
14117 {
14118 402 do
14119 {
14120 469 info = walkflag(x,(bigHitbox?0:8)+(y-hero_newstep),2,up);
14121
14122 469 info = info || walkflag(x+15,(bigHitbox?0:8)+(y-hero_newstep),1,up);
14123 469 info = info || walkflagMBlock(x+15, (bigHitbox?0:8)+(y-hero_newstep));
14124
14125 469 execute(info);
14126
14127
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 339 times.
469 if(info.isUnwalkable())
14128 {
14129
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(y != y.getInt())
14130 {
14131 4 y.doRound();
14132 4 }
14133
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 else if(hero_newstep > 1)
14134 {
14135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(hero_newstep != int32_t(hero_newstep)) //floor
14136 63 hero_newstep = floor((double)hero_newstep);
14137 else --hero_newstep;
14138 63 }
14139 else
14140 63 break;
14141 67 }
14142 339 else walkable = true;
14143
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 339 times.
406 }
14144 406 while(!walkable);
14145 }
14146
14147 674 int32_t s=shiftdir;
14148
14149
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
674 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14150 {
14151 shiftdir=-1;
14152 }
14153 else
14154 {
14155
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 446 times.
674 if(s==left)
14156 {
14157 228 do
14158 {
14159 230 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14160
14161 230 execute(info);
14162
14163
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 227 times.
230 if(info.isUnwalkable())
14164 {
14165
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(x != x.getInt())
14166 {
14167 1 x.doRound();
14168 1 }
14169
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(hero_newstep_diag > 1)
14170 {
14171
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14172 1 hero_newstep_diag.doFloor();
14173 else --hero_newstep_diag;
14174 1 }
14175 else
14176 1 shiftdir = -1;
14177 3 }
14178
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 190 times.
227 else if(walkable)
14179 {
14180 37 do
14181 {
14182 37 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14183 37 execute(info);
14184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(info.isUnwalkable())
14185 {
14186 if(x != x.getInt())
14187 {
14188 x.doRound();
14189 }
14190 else if(hero_newstep_diag > 1)
14191 {
14192 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14193 hero_newstep_diag.doFloor();
14194 else --hero_newstep_diag;
14195 }
14196 else
14197 shiftdir = -1;
14198 }
14199 37 else break;
14200 }
14201 while(shiftdir != -1);
14202 37 break;
14203 }
14204 190 else break;
14205
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 }
14206 3 while(shiftdir != -1);
14207 228 }
14208
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 96 times.
446 else if(s==right)
14209 {
14210 96 do
14211 {
14212 98 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14213
14214 98 execute(info);
14215
14216
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 94 times.
98 if(info.isUnwalkable())
14217 {
14218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(x != x.getInt())
14219 {
14220 x.doRound();
14221 }
14222
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14223 {
14224
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14225 2 hero_newstep_diag.doFloor();
14226 else --hero_newstep_diag;
14227 2 }
14228 else
14229 2 shiftdir = -1;
14230 4 }
14231
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 80 times.
94 else if(walkable)
14232 {
14233 14 do
14234 {
14235 16 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14236 16 execute(info);
14237
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(info.isUnwalkable())
14238 {
14239
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(x != x.getInt())
14240 {
14241 1 x.doRound();
14242 1 }
14243
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(hero_newstep_diag > 1)
14244 {
14245
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14246 1 hero_newstep_diag.doFloor();
14247 else --hero_newstep_diag;
14248 1 }
14249 else
14250 1 shiftdir = -1;
14251 3 }
14252 13 else break;
14253
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 }
14254 3 while(shiftdir != -1);
14255 14 break;
14256 }
14257 80 else break;
14258
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 }
14259 4 while(shiftdir != -1);
14260 96 }
14261 }
14262
14263 674 move(up);
14264 674 shiftdir=s;
14265
14266
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 335 times.
674 if(!walkable)
14267 {
14268
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 65 times.
335 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14269 {
14270 65 x = x.getInt();
14271 65 y = y.getInt();
14272
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 65 times.
100 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14273
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
35 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14274
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14275 {
14276 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14277 sprite::move((zfix)-1,(zfix)0);
14278 }
14279 else
14280 {
14281
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 30 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 65 times.
95 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14282
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14283 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14284 {
14285 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14286 sprite::move((zfix)1,(zfix)0);
14287 }
14288 else
14289 {
14290 65 pushing=push+1;
14291 }
14292 }
14293 65 }
14294 else
14295 {
14296 270 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14297 }
14298 335 }
14299
14300 674 return;
14301 }
14302 }
14303
14304
6/6
✓ Branch 0 taken 1059 times.
✓ Branch 1 taken 7504 times.
✓ Branch 2 taken 1033 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 731 times.
✓ Branch 5 taken 302 times.
8563 if(DrunkDown()&&(holddir==-1||holddir==down))
14305 {
14306
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
757 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14307 {
14308 }
14309 else
14310 {
14311
4/10
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 757 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 757 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
757 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14312 {
14313 757 dir=down;
14314 757 }
14315
14316 757 holddir=down;
14317
14318
3/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 671 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
757 if(DrunkRight()&&shiftdir!=left)
14319 {
14320 86 shiftdir=right;
14321
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
86 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14322
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
86 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14323 86 }
14324
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 609 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 61 times.
671 else if(DrunkLeft()&&shiftdir!=right)
14325 {
14326 61 shiftdir=left;
14327
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14328
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14329 61 }
14330 else
14331 {
14332 610 shiftdir=-1;
14333 }
14334
14335 //bool walkable;
14336
8/12
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 477 times.
✓ Branch 2 taken 280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 137 times.
✓ Branch 6 taken 143 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 143 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 143 times.
757 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14337 {
14338 143 walkable=false;
14339 143 }
14340 else
14341 {
14342 614 do
14343 {
14344 861 info = walkflag(x,15+(y+hero_newstep),2,down);
14345
14346
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 140 times.
861 if(x.getFloor() & 7)
14347 721 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14348 else
14349 140 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14350
14351 861 execute(info);
14352
14353
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 377 times.
861 if(info.isUnwalkable())
14354 {
14355
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 478 times.
484 if(y != y.getInt())
14356 {
14357 6 y.doRound();
14358 6 }
14359
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 237 times.
478 else if(hero_newstep > 1)
14360 {
14361
1/2
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
241 if(hero_newstep != int32_t(hero_newstep)) //floor
14362 241 hero_newstep = floor((double)hero_newstep);
14363 else --hero_newstep;
14364 241 }
14365 else
14366 237 break;
14367 247 }
14368 377 else walkable = true;
14369
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 377 times.
624 }
14370 624 while(!walkable);
14371 }
14372
14373 757 int32_t s=shiftdir;
14374
14375
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
757 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14376 {
14377 shiftdir=-1;
14378 }
14379 else
14380 {
14381
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 696 times.
757 if(s==left)
14382 {
14383 61 do
14384 {
14385 61 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14386
14387 61 execute(info);
14388
14389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(info.isUnwalkable())
14390 {
14391 if(x != x.getInt())
14392 {
14393 x.doRound();
14394 }
14395 else if(hero_newstep_diag > 1)
14396 {
14397 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14398 hero_newstep_diag.doFloor();
14399 else --hero_newstep_diag;
14400 }
14401 else
14402 shiftdir = -1;
14403 }
14404
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 55 times.
61 else if(walkable)
14405 {
14406 6 do
14407 {
14408 6 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14409 6 execute(info);
14410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(info.isUnwalkable())
14411 {
14412 if(x != x.getInt())
14413 {
14414 x.doRound();
14415 }
14416 else if(hero_newstep_diag > 1)
14417 {
14418 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14419 hero_newstep_diag.doFloor();
14420 else --hero_newstep_diag;
14421 }
14422 else
14423 shiftdir = -1;
14424 }
14425 6 else break;
14426 }
14427 while(shiftdir != -1);
14428 6 break;
14429 }
14430 55 else break;
14431 }
14432 while(shiftdir != -1);
14433 61 }
14434
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 86 times.
696 else if(s==right)
14435 {
14436 86 do
14437 {
14438 91 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14439
14440 91 execute(info);
14441
14442
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 83 times.
91 if(info.isUnwalkable())
14443 {
14444
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
8 if(x != x.getInt())
14445 {
14446 1 x.doRound();
14447 1 }
14448
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 else if(hero_newstep_diag > 1)
14449 {
14450
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14451 4 hero_newstep_diag.doFloor();
14452 else --hero_newstep_diag;
14453 4 }
14454 else
14455 3 shiftdir = -1;
14456 8 }
14457
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 70 times.
83 else if(walkable)
14458 {
14459 13 do
14460 {
14461 13 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14462 13 execute(info);
14463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(info.isUnwalkable())
14464 {
14465 if(x != x.getInt())
14466 {
14467 x.doRound();
14468 }
14469 else if(hero_newstep_diag > 1)
14470 {
14471 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14472 hero_newstep_diag.doFloor();
14473 else --hero_newstep_diag;
14474 }
14475 else
14476 shiftdir = -1;
14477 }
14478 13 else break;
14479 }
14480 while(shiftdir != -1);
14481 13 break;
14482 }
14483 70 else break;
14484
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 }
14485 8 while(shiftdir != -1);
14486 86 }
14487 }
14488
14489 757 move(down);
14490 757 shiftdir=s;
14491
14492
2/2
✓ Branch 0 taken 377 times.
✓ Branch 1 taken 380 times.
757 if(!walkable)
14493 {
14494
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 255 times.
380 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14495 {
14496 255 x = x.getInt();
14497 255 y = y.getInt();
14498
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✓ Branch 5 taken 148 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 255 times.
403 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14499
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 132 times.
148 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14500
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14501 {
14502 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14503 sprite::move((zfix)-1,(zfix)0);
14504 }
14505
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 107 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 255 times.
362 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14506
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✗ Branch 5 not taken.
107 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14507 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14508 {
14509 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14510 sprite::move((zfix)1,(zfix)0);
14511 }
14512 else
14513 {
14514 255 pushing=push+1;
14515 }
14516 255 }
14517 else
14518 {
14519 125 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14520 }
14521 380 }
14522
14523 757 return;
14524 }
14525 }
14526
14527
6/6
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 5621 times.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 2123 times.
✓ Branch 5 taken 2 times.
7806 if(DrunkLeft()&&(holddir==-1||holddir==left))
14528 {
14529
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2183 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2183 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14530 {
14531 }
14532 else
14533 {
14534
3/6
✓ Branch 0 taken 2183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2183 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2183 times.
2183 if(charging==0 && spins==0 && action != sideswimattacking)
14535 {
14536 2183 dir=left;
14537 2183 }
14538 2183 sideswimdir = left;
14539
14540 2183 holddir=left;
14541
14542
3/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 2123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
2183 if(DrunkUp()&&shiftdir!=down)
14543 {
14544 60 shiftdir=up;
14545 60 }
14546
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 2023 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
2123 else if(DrunkDown()&&shiftdir!=up)
14547 {
14548 100 shiftdir=down;
14549 100 }
14550 else
14551 {
14552 2023 shiftdir=-1;
14553 }
14554
14555 2183 do
14556 {
14557 2251 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14558
14559 2251 info = info || walkflag(x-hero_newstep,y+15,1,left);
14560
14561 2251 execute(info);
14562
14563
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2117 times.
2251 if(info.isUnwalkable())
14564 {
14565
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 132 times.
134 if(x != x.getInt())
14566 {
14567 2 x.doRound();
14568 2 }
14569
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 66 times.
132 else if(hero_newstep > 1)
14570 {
14571
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(hero_newstep != int32_t(hero_newstep)) //floor
14572 66 hero_newstep = floor((double)hero_newstep);
14573 else --hero_newstep;
14574 66 }
14575 else
14576 66 break;
14577 68 }
14578 2117 else walkable = true;
14579
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 2117 times.
2185 }
14580 2185 while(!walkable);
14581
14582 2183 int32_t s=shiftdir;
14583
14584
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 2183 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1972 times.
✓ Branch 7 taken 211 times.
✓ Branch 8 taken 1931 times.
✓ Branch 9 taken 41 times.
✓ Branch 10 taken 1931 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1931 times.
✗ Branch 13 not taken.
2183 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14585 {
14586 1931 shiftdir=-1;
14587 1931 }
14588 else
14589 {
14590
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 40 times.
252 if(s==up)
14591 {
14592 40 do
14593 {
14594 40 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14595
14596 40 execute(info);
14597
14598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(info.isUnwalkable())
14599 {
14600 if(y != y.getInt())
14601 {
14602 y.doRound();
14603 }
14604 else if(hero_newstep_diag > 1)
14605 {
14606 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14607 hero_newstep_diag.doFloor();
14608 else --hero_newstep_diag;
14609 }
14610 else
14611 shiftdir = -1;
14612 }
14613
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 else if(walkable)
14614 {
14615 40 do
14616 {
14617 40 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14618 40 execute(info);
14619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(info.isUnwalkable())
14620 {
14621 if(y != y.getInt())
14622 {
14623 y.doRound();
14624 }
14625 else if(hero_newstep_diag > 1)
14626 {
14627 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14628 hero_newstep_diag.doFloor();
14629 else --hero_newstep_diag;
14630 }
14631 else
14632 shiftdir = -1;
14633 }
14634 40 else break;
14635 }
14636 while(shiftdir != -1);
14637 40 break;
14638 }
14639 else break;
14640 }
14641 while(shiftdir != -1);
14642 40 }
14643
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 45 times.
212 else if(s==down)
14644 {
14645 45 do
14646 {
14647 45 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14648
14649 45 execute(info);
14650
14651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(info.isUnwalkable())
14652 {
14653 if(y != y.getInt())
14654 {
14655 y.doRound();
14656 }
14657 else if(hero_newstep_diag > 1)
14658 {
14659 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14660 hero_newstep_diag.doFloor();
14661 else --hero_newstep_diag;
14662 }
14663 else
14664 shiftdir = -1;
14665 }
14666
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 16 times.
45 else if(walkable)
14667 {
14668 29 do
14669 {
14670 29 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14671 29 execute(info);
14672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(info.isUnwalkable())
14673 {
14674 if(y != y.getInt())
14675 {
14676 y.doRound();
14677 }
14678 else if(hero_newstep_diag > 1)
14679 {
14680 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14681 hero_newstep_diag.doFloor();
14682 else --hero_newstep_diag;
14683 }
14684 else
14685 shiftdir = -1;
14686 }
14687 29 else break;
14688 }
14689 while(shiftdir != -1);
14690 29 break;
14691 }
14692 16 else break;
14693 }
14694 while(shiftdir != -1);
14695 45 }
14696 }
14697
14698 2183 move(left);
14699 2183 shiftdir=s;
14700
14701
2/2
✓ Branch 0 taken 2117 times.
✓ Branch 1 taken 66 times.
2183 if(!walkable)
14702 {
14703
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 50 times.
66 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14704 {
14705 50 x = x.getInt();
14706 50 y = y.getInt();
14707 50 int32_t v1=bigHitbox?0:8;
14708 50 int32_t v2=bigHitbox?8:12;
14709
14710
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 49 times.
53 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
14711
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
3 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
14712
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
14713 {
14714
4/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
14715 1 sprite::move((zfix)0,(zfix)-1);
14716 1 }
14717
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 49 times.
96 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
14718
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
14719 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
14720 {
14721 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
14722 sprite::move((zfix)0,(zfix)1);
14723 }
14724 else
14725 {
14726 49 pushing=push+1;
14727 }
14728 50 }
14729 else
14730 {
14731 16 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14732
14733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(action!=swimming)
14734 {
14735 16 }
14736 }
14737 66 }
14738
14739 2183 return;
14740 }
14741 }
14742
14743
5/6
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 2505 times.
✓ Branch 2 taken 3042 times.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 3042 times.
✗ Branch 5 not taken.
5623 if(DrunkRight()&&(holddir==-1||holddir==right))
14744 {
14745
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3118 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14746 {
14747 }
14748 else
14749 {
14750
3/6
✓ Branch 0 taken 3118 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3118 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3118 times.
3118 if(charging==0 && spins==0 && action != sideswimattacking)
14751 {
14752 3118 dir=right;
14753 3118 }
14754 3118 sideswimdir = right;
14755
14756 3118 holddir=right;
14757
14758
3/4
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 2863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 255 times.
3118 if(DrunkUp()&&shiftdir!=down)
14759 {
14760 255 shiftdir=up;
14761 255 }
14762
3/4
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 2661 times.
✓ Branch 2 taken 202 times.
✗ Branch 3 not taken.
2863 else if(DrunkDown()&&shiftdir!=up)
14763 {
14764 202 shiftdir=down;
14765 202 }
14766 else
14767 {
14768 2661 shiftdir=-1;
14769 }
14770
14771 3118 do
14772 {
14773 3352 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
14774
14775 3352 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
14776
14777 3352 execute(info);
14778
14779
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 2915 times.
3352 if(info.isUnwalkable())
14780 {
14781
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 426 times.
437 if(x != x.getInt())
14782 {
14783 11 x.doRound();
14784 11 }
14785
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 203 times.
426 else if(hero_newstep > 1)
14786 {
14787
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if(hero_newstep != int32_t(hero_newstep)) //floor
14788 223 hero_newstep = floor((double)hero_newstep);
14789 else --hero_newstep;
14790 223 }
14791 else
14792 203 break;
14793 234 }
14794 2915 else walkable = true;
14795
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 2915 times.
3149 }
14796 3149 while(!walkable);
14797
14798 3118 int32_t s=shiftdir;
14799
14800
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2133 times.
✓ Branch 7 taken 985 times.
✓ Branch 8 taken 2127 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 2127 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2127 times.
✗ Branch 13 not taken.
3118 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14801 {
14802 2127 shiftdir=-1;
14803 2127 }
14804 else
14805 {
14806
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 229 times.
991 if(s==up)
14807 {
14808 229 do
14809 {
14810 270 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14811
14812 270 execute(info);
14813
14814
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 192 times.
270 if(info.isUnwalkable())
14815 {
14816
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 74 times.
78 if(y != y.getInt())
14817 {
14818 4 y.doRound();
14819 4 }
14820
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 37 times.
74 else if(hero_newstep_diag > 1)
14821 {
14822
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14823 37 hero_newstep_diag.doFloor();
14824 else --hero_newstep_diag;
14825 37 }
14826 else
14827 37 shiftdir = -1;
14828 78 }
14829
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 29 times.
192 else if(walkable)
14830 {
14831 163 do
14832 {
14833 163 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14834 163 execute(info);
14835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
163 if(info.isUnwalkable())
14836 {
14837 if(y != y.getInt())
14838 {
14839 y.doRound();
14840 }
14841 else if(hero_newstep_diag > 1)
14842 {
14843 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14844 hero_newstep_diag.doFloor();
14845 else --hero_newstep_diag;
14846 }
14847 else
14848 shiftdir = -1;
14849 }
14850 163 else break;
14851 }
14852 while(shiftdir != -1);
14853 163 break;
14854 }
14855 29 else break;
14856
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 37 times.
78 }
14857 78 while(shiftdir != -1);
14858 229 }
14859
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 96 times.
762 else if(s==down)
14860 {
14861 96 do
14862 {
14863 96 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14864
14865 96 execute(info);
14866
14867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(info.isUnwalkable())
14868 {
14869 if(y != y.getInt())
14870 {
14871 y.doRound();
14872 }
14873 else if(hero_newstep_diag > 1)
14874 {
14875 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14876 hero_newstep_diag.doFloor();
14877 else --hero_newstep_diag;
14878 }
14879 else
14880 shiftdir = -1;
14881 }
14882
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 53 times.
96 else if(walkable)
14883 {
14884 43 do
14885 {
14886 43 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
14887 43 execute(info);
14888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(info.isUnwalkable())
14889 {
14890 if(y != y.getInt())
14891 {
14892 y.doRound();
14893 }
14894 else if(hero_newstep_diag > 1)
14895 {
14896 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14897 hero_newstep_diag.doFloor();
14898 else --hero_newstep_diag;
14899 }
14900 else
14901 shiftdir = -1;
14902 }
14903 43 else break;
14904 }
14905 while(shiftdir != -1);
14906 43 break;
14907 }
14908 53 else break;
14909 }
14910 while(shiftdir != -1);
14911 96 }
14912 }
14913
14914 3118 move(right);
14915 3118 shiftdir=s;
14916
14917
2/2
✓ Branch 0 taken 2915 times.
✓ Branch 1 taken 203 times.
3118 if(!walkable)
14918 {
14919
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 121 times.
203 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14920 {
14921 121 x = x.getInt();
14922 121 y = y.getInt();
14923 121 int32_t v1=bigHitbox?0:8;
14924 121 int32_t v2=bigHitbox?8:12;
14925
14926
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 121 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 101 times.
149 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14927
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 20 times.
28 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
14928
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14929 {
14930
4/8
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
20 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
14931 20 sprite::move((zfix)0,(zfix)-1);
14932 20 }
14933
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 93 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101 times.
194 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14934
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
14935 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14936 {
14937 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
14938 sprite::move((zfix)0,(zfix)1);
14939 }
14940 else
14941 {
14942 101 pushing=push+1;
14943 101 z3step=2;
14944 }
14945 121 }
14946 else
14947 {
14948 82 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14949
14950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(action!=swimming)
14951 {
14952 82 }
14953 }
14954 203 }
14955
14956 3118 return;
14957 }
14958 }
14959 2505 }
14960 else
14961 {
14962 if(DrunkUp()&&(holddir==-1||holddir==up))
14963 {
14964 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14965 {
14966 }
14967 else
14968 {
14969 if(charging==0 && spins==0)
14970 {
14971 dir=up;
14972 }
14973
14974 holddir=up;
14975
14976 if(DrunkRight()&&shiftdir!=left)
14977 {
14978 shiftdir=right;
14979 }
14980 else if(DrunkLeft()&&shiftdir!=right)
14981 {
14982 shiftdir=left;
14983 }
14984 else
14985 {
14986 shiftdir=-1;
14987 }
14988
14989 //walkable if Ladder can be placed or is already placed vertically
14990 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14991 {
14992 walkable=false;
14993 }
14994 else
14995 {
14996 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14997
14998 if(x.getInt() & 7)
14999 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15000 else
15001 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15002
15003 execute(info);
15004
15005 if(info.isUnwalkable())
15006 {
15007 if(z3step==2)
15008 {
15009 z3step=1;
15010 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15011
15012 if(x.getInt()&7)
15013 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15014 else
15015 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15016
15017 execute(info);
15018
15019 if(info.isUnwalkable())
15020 {
15021 walkable = false;
15022 }
15023 else
15024 {
15025 walkable=true;
15026 }
15027 }
15028 else
15029 {
15030 walkable=false;
15031 }
15032 }
15033 else
15034 {
15035 walkable = true;
15036 }
15037 }
15038
15039 int32_t s=shiftdir;
15040
15041 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15042 {
15043 shiftdir=-1;
15044 }
15045 else
15046 {
15047 if(s==left)
15048 {
15049 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15050 execute(info);
15051
15052 if(info.isUnwalkable())
15053 {
15054 shiftdir=-1;
15055 }
15056 else if(walkable)
15057 {
15058 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15059 execute(info);
15060 if(info.isUnwalkable())
15061 {
15062 shiftdir=-1;
15063 }
15064 }
15065 }
15066 else if(s==right)
15067 {
15068 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15069 execute(info);
15070
15071 if(info.isUnwalkable())
15072 {
15073 shiftdir=-1;
15074 }
15075 else if(walkable)
15076 {
15077 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15078 execute(info);
15079
15080 if(info.isUnwalkable())
15081 {
15082 shiftdir=-1;
15083 }
15084 }
15085 }
15086 }
15087
15088 move(up);
15089 shiftdir=s;
15090
15091 if(!walkable)
15092 {
15093 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15094 {
15095 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15096 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15097 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15098 {
15099 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15100 sprite::move((zfix)-1,(zfix)0);
15101 }
15102 else
15103 {
15104 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15105 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15106 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15107 {
15108 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15109 sprite::move((zfix)1,(zfix)0);
15110 }
15111 else
15112 {
15113 pushing=push+1;
15114 }
15115 }
15116
15117 z3step=2;
15118 }
15119 else
15120 {
15121 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15122 z3step=2;
15123 }
15124 }
15125
15126 return;
15127 }
15128 }
15129
15130 if(DrunkDown()&&(holddir==-1||holddir==down))
15131 {
15132 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15133 {
15134 }
15135 else
15136 {
15137 if(charging==0 && spins==0)
15138 {
15139 dir=down;
15140 }
15141
15142 holddir=down;
15143
15144 if(DrunkRight()&&shiftdir!=left)
15145 {
15146 shiftdir=right;
15147 }
15148 else if(DrunkLeft()&&shiftdir!=right)
15149 {
15150 shiftdir=left;
15151 }
15152 else
15153 {
15154 shiftdir=-1;
15155 }
15156
15157 //bool walkable;
15158 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15159 {
15160 walkable=false;
15161 }
15162 else
15163 {
15164 info = walkflag(x,y+15+z3step,2,down);
15165
15166 if(x.getInt()&7)
15167 info = info || walkflag(x+16,y+15+z3step,1,down);
15168 else
15169 info = info || walkflagMBlock(x+16, y+15+z3step);
15170
15171 execute(info);
15172
15173 if(info.isUnwalkable())
15174 {
15175 if(z3step==2)
15176 {
15177 z3step=1;
15178 info = walkflag(x,y+15+z3step,2,down);
15179
15180 if(x.getInt()&7)
15181 info = info || walkflag(x+16,y+15+z3step,1,down);
15182 else
15183 info = info || walkflagMBlock(x+16, y+15+z3step);
15184
15185 execute(info);
15186
15187 if(info.isUnwalkable())
15188 {
15189 walkable = false;
15190 }
15191 else
15192 {
15193 walkable=true;
15194 }
15195 }
15196 else
15197 {
15198 walkable=false;
15199 }
15200 }
15201 else
15202 {
15203 walkable = true;
15204 }
15205 }
15206
15207 int32_t s=shiftdir;
15208
15209 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15210 {
15211 shiftdir=-1;
15212 }
15213 else
15214 {
15215 if(s==left)
15216 {
15217 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15218 execute(info);
15219
15220 if(info.isUnwalkable())
15221 {
15222 shiftdir=-1;
15223 }
15224 else if(walkable)
15225 {
15226 info = walkflag(x-1,y+16,1,left);
15227 execute(info);
15228
15229 if(info.isUnwalkable())
15230 {
15231 shiftdir=-1;
15232 }
15233 }
15234 }
15235 else if(s==right)
15236 {
15237 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15238 execute(info);
15239
15240 if(info.isUnwalkable())
15241 {
15242 shiftdir=-1;
15243 }
15244 else if(walkable)
15245 {
15246 info = walkflag(x+16,y+16,1,right);
15247 execute(info);
15248
15249 if(info.isUnwalkable())
15250 {
15251 shiftdir=-1;
15252 }
15253 }
15254 }
15255 }
15256
15257 move(down);
15258 shiftdir=s;
15259
15260 if(!walkable)
15261 {
15262 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15263 {
15264 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15265 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15266 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15267 {
15268 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15269 sprite::move((zfix)-1,(zfix)0);
15270 }
15271 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15272 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15273 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15274 {
15275 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15276 sprite::move((zfix)1,(zfix)0);
15277 }
15278 else //if(shiftdir==-1)
15279 {
15280 pushing=push+1;
15281
15282 if(action!=swimming)
15283 {
15284 }
15285 }
15286
15287 z3step=2;
15288 }
15289 else
15290 {
15291 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15292
15293 if(action!=swimming)
15294 {
15295 }
15296
15297 z3step=2;
15298 }
15299 }
15300
15301 return;
15302 }
15303 }
15304
15305 if(DrunkLeft()&&(holddir==-1||holddir==left))
15306 {
15307 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15308 {
15309 }
15310 else
15311 {
15312 if(charging==0 && spins==0)
15313 {
15314 dir=left;
15315 }
15316
15317 holddir=left;
15318
15319 if(DrunkUp()&&shiftdir!=down)
15320 {
15321 shiftdir=up;
15322 }
15323 else if(DrunkDown()&&shiftdir!=up)
15324 {
15325 shiftdir=down;
15326 }
15327 else
15328 {
15329 shiftdir=-1;
15330 }
15331
15332 //bool walkable;
15333 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15334
15335 if(y.getInt()&7)
15336 info = info || walkflag(x-z3step,y+16,1,left);
15337
15338 execute(info);
15339
15340 if(info.isUnwalkable())
15341 {
15342 if(z3step==2)
15343 {
15344 z3step=1;
15345 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15346
15347 if(y.getInt()&7)
15348 info = info || walkflag(x-z3step,y+16,1,left);
15349
15350 execute(info);
15351
15352 if(info.isUnwalkable())
15353 {
15354 walkable = false;
15355 }
15356 else
15357 {
15358 walkable=true;
15359 }
15360 }
15361 else
15362 {
15363 walkable=false;
15364 }
15365 }
15366 else
15367 {
15368 walkable = true;
15369 }
15370
15371 int32_t s=shiftdir;
15372
15373 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15374 {
15375 shiftdir=-1;
15376 }
15377 else
15378 {
15379 if(s==up)
15380 {
15381 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15382 execute(info);
15383
15384 if(info.isUnwalkable())
15385 {
15386 shiftdir=-1;
15387 }
15388 else if(walkable)
15389 {
15390 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15391 execute(info);
15392
15393 if(info.isUnwalkable())
15394 {
15395 shiftdir=-1;
15396 }
15397 }
15398 }
15399 else if(s==down)
15400 {
15401 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15402 execute(info);
15403
15404 if(info.isUnwalkable())
15405 {
15406 shiftdir=-1;
15407 }
15408 else if(walkable)
15409 {
15410 info = walkflag(x-1,y+16,1,down);
15411 execute(info);
15412
15413 if(info.isUnwalkable())
15414 {
15415 shiftdir=-1;
15416 }
15417 }
15418 }
15419 }
15420
15421 move(left);
15422 shiftdir=s;
15423
15424 if(!walkable)
15425 {
15426 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15427 {
15428 int32_t v1=bigHitbox?0:8;
15429 int32_t v2=bigHitbox?8:12;
15430
15431 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15432 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15433 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15434 {
15435 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15436 sprite::move((zfix)0,(zfix)-1);
15437 }
15438 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15439 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15440 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15441 {
15442 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15443 sprite::move((zfix)0,(zfix)1);
15444 }
15445 else //if(shiftdir==-1)
15446 {
15447 pushing=push+1;
15448
15449 if(action!=swimming)
15450 {
15451 }
15452 }
15453
15454 z3step=2;
15455 }
15456 else
15457 {
15458 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15459
15460 if(action!=swimming)
15461 {
15462 }
15463
15464 z3step=2;
15465 }
15466 }
15467
15468 return;
15469 }
15470 }
15471
15472 if(DrunkRight()&&(holddir==-1||holddir==right))
15473 {
15474 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15475 {
15476 }
15477 else
15478 {
15479 if(charging==0 && spins==0)
15480 {
15481 dir=right;
15482 }
15483
15484 holddir=right;
15485
15486 if(DrunkUp()&&shiftdir!=down)
15487 {
15488 shiftdir=up;
15489 }
15490 else if(DrunkDown()&&shiftdir!=up)
15491 {
15492 shiftdir=down;
15493 }
15494 else
15495 {
15496 shiftdir=-1;
15497 }
15498
15499 //bool walkable;
15500 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15501
15502 if(y.getInt()&7)
15503 info = info || walkflag(x+15+z3step,y+16,1,right);
15504
15505 execute(info);
15506
15507 if(info.isUnwalkable())
15508 {
15509 if(z3step==2)
15510 {
15511 z3step=1;
15512 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15513
15514 if(y.getInt()&7)
15515 info = info || walkflag(x+15+z3step,y+16,1,right);
15516
15517 execute(info);
15518
15519 if(info.isUnwalkable())
15520 {
15521 walkable = false;
15522 }
15523 else
15524 {
15525 walkable=true;
15526 }
15527 }
15528 else
15529 {
15530 walkable=false;
15531 }
15532 }
15533 else
15534 {
15535 walkable = true;
15536 }
15537
15538 int32_t s=shiftdir;
15539
15540 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15541 {
15542 shiftdir=-1;
15543 }
15544 else
15545 {
15546 if(s==up)
15547 {
15548 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15549 execute(info);
15550
15551 if(info.isUnwalkable())
15552 {
15553 shiftdir=-1;
15554 }
15555 else if(walkable)
15556 {
15557 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15558 execute(info);
15559
15560 if(info.isUnwalkable())
15561 {
15562 shiftdir=-1;
15563 }
15564 }
15565 }
15566 else if(s==down)
15567 {
15568 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15569 execute(info);
15570
15571 if(info.isUnwalkable())
15572 {
15573 shiftdir=-1;
15574 }
15575 else if(walkable)
15576 {
15577 info = walkflag(x+16,y+16,1,down);
15578 execute(info);
15579
15580 if(info.isUnwalkable())
15581 {
15582 shiftdir=-1;
15583 }
15584 }
15585 }
15586 }
15587
15588 move(right);
15589 shiftdir=s;
15590
15591 if(!walkable)
15592 {
15593 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15594 {
15595 int32_t v1=bigHitbox?0:8;
15596 int32_t v2=bigHitbox?8:12;
15597
15598 info = !walkflag(x+16,y+v1,1,right)&&
15599 !walkflag(x+16,y+v2,1,right)&&
15600 walkflag(x+16,y+15,1,right);
15601
15602 //do NOT execute these
15603 if(info.isUnwalkable())
15604 {
15605 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15606 sprite::move((zfix)0,(zfix)-1);
15607 }
15608 else
15609 {
15610 info = walkflag(x+16,y+v1, 1,right)&&
15611 !walkflag(x+16,y+v2-1,1,right)&&
15612 !walkflag(x+16,y+15, 1,right);
15613
15614 if(info.isUnwalkable())
15615 {
15616 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15617 sprite::move((zfix)0,(zfix)1);
15618 }
15619 else //if(shiftdir==-1)
15620 {
15621 pushing=push+1;
15622 z3step=2;
15623
15624 if(action!=swimming)
15625 {
15626 }
15627 }
15628 }
15629
15630 z3step=2;
15631 }
15632 else
15633 {
15634 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15635
15636 if(action!=swimming)
15637 {
15638 }
15639
15640 z3step=2;
15641 }
15642 }
15643
15644 return;
15645 }
15646 }
15647 }
15648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2505 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2505 if(shield_forcedir > -1 && action != rafting)
15649 dir = shield_forcedir;
15650 2505 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15651 2505 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15652 2505 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15653 2505 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15654 2505 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15655
15656
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 2505 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
2505 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15657 {
15658 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15659 {
15660 //action=swimming;
15661 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15662 {
15663 hopclk = 0xFF;
15664 }
15665 }
15666 }
15667
15668 2505 return;
15669 } //endif (LTTPWALK)
15670 823122 temp_step = hero_newstep;
15671 823122 temp_x = x;
15672 823122 temp_y = y;
15673
15674
7/8
✓ Branch 0 taken 636052 times.
✓ Branch 1 taken 187070 times.
✓ Branch 2 taken 629039 times.
✓ Branch 3 taken 7013 times.
✓ Branch 4 taken 6490 times.
✓ Branch 5 taken 629562 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6490 times.
823122 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15675 {
15676
2/4
✓ Branch 0 taken 6490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6490 times.
6490 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15677 goto LEFTRIGHT_NEWMOVE;
15678 6490 else goto LEFTRIGHT_OLDMOVE;
15679 }
15680
15681 // make it easier to get in left & right doors
15682
15683 //ignore ladder for this part. sigh sigh sigh -DD
15684 816632 oldladderx = ladderx;
15685 816632 oldladdery = laddery;
15686
2/4
✓ Branch 0 taken 816632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 816632 times.
816632 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15687 {
15688 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
15689 {
15690 do
15691 {
15692 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
15693 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
15694
15695 if(info.isUnwalkable())
15696 {
15697 if(temp_x != int32_t(temp_x))
15698 {
15699 temp_x = floor((double)temp_x);
15700 }
15701 else if(temp_step > 1)
15702 {
15703 if(temp_step != int32_t(temp_step)) //floor
15704 temp_step = floor((double)temp_step);
15705 else --temp_step;
15706 }
15707 else
15708 break;
15709 }
15710 }
15711 while(info.isUnwalkable());
15712
15713 if(!info.isUnwalkable())
15714 {
15715 x = temp_x;
15716 y = temp_y;
15717 hero_newstep = temp_step;
15718 //ONLY process the side-effects of the above walkflag if Hero will actually move
15719 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
15720 execute(info);
15721 move(left);
15722 return;
15723 }
15724 temp_x = x;
15725 temp_y = y;
15726 temp_step = hero_newstep;
15727 }
15728
15729 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
15730 {
15731 do
15732 {
15733 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
15734 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15735
15736 if(info.isUnwalkable())
15737 {
15738 if(temp_x != int32_t(temp_x))
15739 {
15740 temp_x = floor((double)temp_x);
15741 }
15742 else if(temp_step > 1)
15743 {
15744 if(temp_step != int32_t(temp_step)) //floor
15745 temp_step = floor((double)temp_step);
15746 else --temp_step;
15747 }
15748 else
15749 break;
15750 }
15751 }
15752 while(info.isUnwalkable());
15753
15754 if(!info.isUnwalkable())
15755 {
15756 x = temp_x;
15757 y = temp_y;
15758 hero_newstep = temp_step;
15759 execute(info);
15760 move(right);
15761 return;
15762 }
15763 temp_x = x;
15764 temp_y = y;
15765 temp_step = hero_newstep;
15766 }
15767
15768 ladderx = oldladderx;
15769 laddery = oldladdery;
15770
15771 if(DrunkUp())
15772 {
15773 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15774 {
15775 if(dir!=up && dir!=down)
15776 {
15777 if(xoff>2&&xoff<6)
15778 {
15779 move(dir);
15780 }
15781 else if(xoff>=6)
15782 {
15783 move(right);
15784 }
15785 else if(xoff>=1)
15786 {
15787 move(left);
15788 }
15789 }
15790 else
15791 {
15792 if(xoff>=4)
15793 {
15794 move(right);
15795 }
15796 else if(xoff<4)
15797 {
15798 move(left);
15799 }
15800 }
15801 }
15802 else
15803 {
15804 do
15805 {
15806 if(action==swimming || IsSideSwim() || action == swimhit)
15807 {
15808 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15809
15810 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
15811 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
15812 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
15813 info.setUnwalkable(true);
15814 }
15815 else
15816 {
15817 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15818 if(x.getInt() & 7)
15819 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
15820 else
15821 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15822 }
15823
15824 if(info.isUnwalkable())
15825 {
15826 if(temp_y != int32_t(temp_y))
15827 {
15828 temp_y = floor((double)temp_y);
15829 }
15830 else if(temp_step > 1)
15831 {
15832 if(temp_step != int32_t(temp_step)) //floor
15833 temp_step = floor((double)temp_step);
15834 else --temp_step;
15835 }
15836 else
15837 break;
15838 }
15839 }
15840 while(info.isUnwalkable());
15841
15842 execute(info);
15843
15844 if(!info.isUnwalkable())
15845 {
15846 x = temp_x;
15847 y = temp_y;
15848 hero_newstep = temp_step;
15849 move(up);
15850 return;
15851 }
15852
15853 if(!DrunkLeft() && !DrunkRight())
15854 {
15855 if(NO_GRIDLOCK)
15856 {
15857 x = x.getInt();
15858 y = y.getInt();
15859 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15860 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15861 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15862 {
15863 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15864 sprite::move((zfix)-1,(zfix)0);
15865 }
15866 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15867 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15868 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15869 {
15870 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15871 sprite::move((zfix)1,(zfix)0);
15872 }
15873 else
15874 {
15875 pushing=push+1;
15876 }
15877 }
15878 else pushing=push+1;
15879
15880 if(charging==0 && spins==0)
15881 {
15882 dir=up;
15883 }
15884
15885 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15886 {
15887 herostep();
15888 }
15889
15890 return;
15891 }
15892 else
15893 {
15894 goto LEFTRIGHT_NEWMOVE;
15895 }
15896 }
15897
15898 return;
15899 }
15900
15901 if(DrunkDown())
15902 {
15903 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15904 {
15905 if(dir!=up && dir!=down)
15906 {
15907 if(xoff>2&&xoff<6)
15908 {
15909 move(dir);
15910 }
15911 else if(xoff>=6)
15912 {
15913 move(right);
15914 }
15915 else if(xoff>=1)
15916 {
15917 move(left);
15918 }
15919 }
15920 else
15921 {
15922 if(xoff>=4)
15923 {
15924 move(right);
15925 }
15926 else if(xoff<4)
15927 {
15928 move(left);
15929 }
15930 }
15931 }
15932 else
15933 {
15934 do
15935 {
15936 if(action==swimming || IsSideSwim() || action == swimhit)
15937 {
15938 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15939
15940 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
15941 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
15942 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
15943 info.setUnwalkable(true);
15944 }
15945 else
15946 {
15947 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15948 if(x.getInt() & 7)
15949 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
15950 else
15951 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15952 }
15953
15954 if(info.isUnwalkable())
15955 {
15956 if(temp_y != int32_t(temp_y))
15957 {
15958 temp_y = floor((double)temp_y);
15959 }
15960 else if(temp_step > 1)
15961 {
15962 if(temp_step != int32_t(temp_step)) //floor
15963 temp_step = floor((double)temp_step);
15964 else --temp_step;
15965 }
15966 else
15967 break;
15968 }
15969 }
15970 while(info.isUnwalkable());
15971
15972 execute(info);
15973
15974 if(!info.isUnwalkable())
15975 {
15976 x = temp_x;
15977 y = temp_y;
15978 hero_newstep = temp_step;
15979 move(down);
15980 return;
15981 }
15982
15983 if(!DrunkLeft() && !DrunkRight())
15984 {
15985 if(NO_GRIDLOCK)
15986 {
15987 x = x.getInt();
15988 y = y.getInt();
15989 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15990 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15991 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15992 {
15993 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15994 sprite::move((zfix)-1,(zfix)0);
15995 }
15996 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15997 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15998 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15999 {
16000 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16001 sprite::move((zfix)1,(zfix)0);
16002 }
16003 else
16004 {
16005 pushing=push+1;
16006 }
16007 }
16008 else pushing=push+1;
16009
16010 if(charging==0 && spins==0)
16011 {
16012 dir=down;
16013 }
16014
16015 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16016 {
16017 herostep();
16018 }
16019
16020 return;
16021 }
16022 else goto LEFTRIGHT_NEWMOVE;
16023 }
16024
16025 return;
16026 }
16027
16028 LEFTRIGHT_NEWMOVE:
16029 temp_x = x;
16030 temp_y = y;
16031 temp_step = hero_newstep;
16032 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16033 {
16034 return;
16035 }
16036
16037 if(DrunkLeft())
16038 {
16039 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16040 {
16041 if(dir!=left && dir!=right)
16042 {
16043 if(yoff>2&&yoff<6)
16044 {
16045 move(dir);
16046 }
16047 else if(yoff>=6)
16048 {
16049 move(down);
16050 }
16051 else if(yoff>=1)
16052 {
16053 move(up);
16054 }
16055 }
16056 else
16057 {
16058 if(yoff>=4)
16059 {
16060 move(down);
16061 }
16062 else if(yoff<4)
16063 {
16064 move(up);
16065 }
16066 }
16067 }
16068 else
16069 {
16070 do
16071 {
16072 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16073 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16074
16075 if(y.getInt() & 7)
16076 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16077
16078 if(info.isUnwalkable())
16079 {
16080 if(temp_x != int32_t(temp_x))
16081 {
16082 temp_x = floor((double)temp_x);
16083 }
16084 else if(temp_step > 1)
16085 {
16086 if(temp_step != int32_t(temp_step)) //floor
16087 temp_step = floor((double)temp_step);
16088 else --temp_step;
16089 }
16090 else
16091 break;
16092 }
16093 }
16094 while(info.isUnwalkable());
16095
16096 execute(info);
16097
16098 if(!info.isUnwalkable())
16099 {
16100 x = temp_x;
16101 y = temp_y;
16102 hero_newstep = temp_step;
16103 move(left);
16104 return;
16105 }
16106
16107 if(!DrunkUp() && !DrunkDown())
16108 {
16109 if(NO_GRIDLOCK)
16110 {
16111 x = x.getInt();
16112 y = y.getInt();
16113 int32_t v1=bigHitbox?0:8;
16114 int32_t v2=bigHitbox?8:12;
16115
16116 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16117 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16118 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16119 {
16120 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16121 sprite::move((zfix)0,(zfix)-1);
16122 }
16123 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16124 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16125 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16126 {
16127 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16128 sprite::move((zfix)0,(zfix)1);
16129 }
16130 else
16131 {
16132 pushing=push+1;
16133 }
16134 }
16135 else pushing=push+1;
16136
16137 if(charging==0 && spins==0)
16138 {
16139 dir=left;
16140 }
16141
16142 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16143 {
16144 herostep();
16145 }
16146
16147 return;
16148 }
16149 }
16150
16151 return;
16152 }
16153
16154 if(DrunkRight())
16155 {
16156 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16157 {
16158 if(dir!=left && dir!=right)
16159 {
16160 if(yoff>2&&yoff<6)
16161 {
16162 move(dir);
16163 }
16164 else if(yoff>=6)
16165 {
16166 move(down);
16167 }
16168 else if(yoff>=1)
16169 {
16170 move(up);
16171 }
16172 }
16173 else
16174 {
16175 if(yoff>=4)
16176 {
16177 move(down);
16178 }
16179 else if(yoff<4)
16180 {
16181 move(up);
16182 }
16183 }
16184 }
16185 else
16186 {
16187 do
16188 {
16189 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16190 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16191
16192 if(y.getInt() & 7)
16193 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16194
16195 if(info.isUnwalkable())
16196 {
16197 if(temp_x != int32_t(temp_x))
16198 {
16199 temp_x = floor((double)temp_x);
16200 }
16201 else if(temp_step > 1)
16202 {
16203 if(temp_step != int32_t(temp_step)) //floor
16204 temp_step = floor((double)temp_step);
16205 else --temp_step;
16206 }
16207 else
16208 break;
16209 }
16210 }
16211 while(info.isUnwalkable());
16212
16213 execute(info);
16214
16215 if(!info.isUnwalkable())
16216 {
16217 x = temp_x;
16218 y = temp_y;
16219 hero_newstep = temp_step;
16220 move(right);
16221 return;
16222 }
16223
16224 if(!DrunkUp() && !DrunkDown())
16225 {
16226 if(NO_GRIDLOCK)
16227 {
16228 x = x.getInt();
16229 y = y.getInt();
16230 int32_t v1=bigHitbox?0:8;
16231 int32_t v2=bigHitbox?8:12;
16232
16233 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16234 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16235 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16236 {
16237 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16238 sprite::move((zfix)0,(zfix)-1);
16239 }
16240 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16241 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16242 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16243 {
16244 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16245 sprite::move((zfix)0,(zfix)1);
16246 }
16247 else
16248 {
16249 pushing=push+1;
16250 }
16251 }
16252 else pushing=push+1;
16253
16254 if(charging==0 && spins==0)
16255 {
16256 dir=right;
16257 }
16258
16259 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16260 {
16261 herostep();
16262 }
16263
16264 return;
16265 }
16266 }
16267 }
16268 }
16269 else
16270 {
16271 1633264 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16272 816632 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16273
16274
10/10
✓ Branch 0 taken 629562 times.
✓ Branch 1 taken 187070 times.
✓ Branch 2 taken 70799 times.
✓ Branch 3 taken 558763 times.
✓ Branch 4 taken 54530 times.
✓ Branch 5 taken 16269 times.
✓ Branch 6 taken 385 times.
✓ Branch 7 taken 54145 times.
✓ Branch 8 taken 337 times.
✓ Branch 9 taken 48 times.
816632 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16275 {
16276 //ONLY process the side-effects of the above walkflag if Hero will actually move
16277 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16278 337 execute(info);
16279 337 move(left);
16280 337 return;
16281 }
16282
16283 1632590 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16284 816295 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16285
16286
10/10
✓ Branch 0 taken 629225 times.
✓ Branch 1 taken 187070 times.
✓ Branch 2 taken 75864 times.
✓ Branch 3 taken 553361 times.
✓ Branch 4 taken 57114 times.
✓ Branch 5 taken 18750 times.
✓ Branch 6 taken 473 times.
✓ Branch 7 taken 56641 times.
✓ Branch 8 taken 38 times.
✓ Branch 9 taken 435 times.
816295 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16287 {
16288 435 execute(info);
16289 435 move(right);
16290 435 return;
16291 }
16292
16293 815860 ladderx = oldladderx;
16294 815860 laddery = oldladdery;
16295
16296
2/2
✓ Branch 0 taken 91422 times.
✓ Branch 1 taken 724438 times.
815860 if(DrunkUp())
16297 {
16298
10/14
✓ Branch 0 taken 2623 times.
✓ Branch 1 taken 88799 times.
✓ Branch 2 taken 2610 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 2573 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 2573 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2573 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2573 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2573 times.
91422 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16299 {
16300
2/4
✓ Branch 0 taken 2573 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2573 times.
2573 if(dir!=up && dir!=down)
16301 {
16302
4/4
✓ Branch 0 taken 1781 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 767 times.
✓ Branch 3 taken 1014 times.
2573 if(xoff>2&&xoff<6)
16303 {
16304 1014 move(dir);
16305 1014 }
16306
2/2
✓ Branch 0 taken 767 times.
✓ Branch 1 taken 792 times.
1559 else if(xoff>=6)
16307 {
16308 767 move(right);
16309 767 }
16310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 else if(xoff>=1)
16311 {
16312 792 move(left);
16313 792 }
16314 2573 }
16315 else
16316 {
16317 if(xoff>=4)
16318 {
16319 move(right);
16320 }
16321 else if(xoff<4)
16322 {
16323 move(left);
16324 }
16325 }
16326 2573 }
16327 else
16328 {
16329
4/6
✓ Branch 0 taken 87791 times.
✓ Branch 1 taken 1058 times.
✓ Branch 2 taken 87791 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 87791 times.
88849 if(action==swimming || IsSideSwim() || action == swimhit)
16330 {
16331 1058 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16332
16333
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1058 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1058 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 1050 times.
✓ Branch 6 taken 1002 times.
✓ Branch 7 taken 56 times.
2108 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16334
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 994 times.
2044 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16335 994 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16336 56 info.setUnwalkable(true);
16337 1058 }
16338 else
16339 {
16340 87791 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16341
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 87778 times.
87791 if(x.getInt() & 7)
16342 13 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16343 else
16344 87778 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16345 }
16346
16347 88849 execute(info);
16348
16349
2/2
✓ Branch 0 taken 29742 times.
✓ Branch 1 taken 59107 times.
88849 if(!info.isUnwalkable())
16350 {
16351 59107 move(up);
16352 59107 return;
16353 }
16354
16355
4/4
✓ Branch 0 taken 28295 times.
✓ Branch 1 taken 1447 times.
✓ Branch 2 taken 1754 times.
✓ Branch 3 taken 26541 times.
29742 if(!DrunkLeft() && !DrunkRight())
16356 {
16357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26541 times.
26541 if(NO_GRIDLOCK)
16358 {
16359 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16360 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16361 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16362 {
16363 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16364 sprite::move((zfix)-1,(zfix)0);
16365 }
16366 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16367 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16368 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16369 {
16370 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16371 sprite::move((zfix)1,(zfix)0);
16372 }
16373 else
16374 {
16375 pushing=push+1;
16376 }
16377 }
16378 26541 else pushing=push+1;
16379
16380
2/4
✓ Branch 0 taken 26541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26541 times.
✗ Branch 3 not taken.
26541 if(charging==0 && spins==0)
16381 {
16382 26541 dir=up;
16383 26541 }
16384
16385
5/8
✓ Branch 0 taken 26498 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 26498 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26498 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 26498 times.
26541 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16386 {
16387 26498 herostep();
16388 26498 }
16389
16390 26541 return;
16391 }
16392 else
16393 {
16394 3201 goto LEFTRIGHT_OLDMOVE;
16395 }
16396 }
16397
16398 2573 return;
16399 }
16400
16401
2/2
✓ Branch 0 taken 76488 times.
✓ Branch 1 taken 647950 times.
724438 if(DrunkDown())
16402 {
16403
10/14
✓ Branch 0 taken 2062 times.
✓ Branch 1 taken 74426 times.
✓ Branch 2 taken 2050 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 1947 times.
✓ Branch 5 taken 103 times.
✓ Branch 6 taken 1947 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1947 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1947 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1947 times.
76488 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16404 {
16405
2/4
✓ Branch 0 taken 1947 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1947 times.
1947 if(dir!=up && dir!=down)
16406 {
16407
4/4
✓ Branch 0 taken 1399 times.
✓ Branch 1 taken 548 times.
✓ Branch 2 taken 610 times.
✓ Branch 3 taken 789 times.
1947 if(xoff>2&&xoff<6)
16408 {
16409 789 move(dir);
16410 789 }
16411
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 548 times.
1158 else if(xoff>=6)
16412 {
16413 610 move(right);
16414 610 }
16415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 548 times.
548 else if(xoff>=1)
16416 {
16417 548 move(left);
16418 548 }
16419 1947 }
16420 else
16421 {
16422 if(xoff>=4)
16423 {
16424 move(right);
16425 }
16426 else if(xoff<4)
16427 {
16428 move(left);
16429 }
16430 }
16431 1947 }
16432 else
16433 {
16434
4/6
✓ Branch 0 taken 72696 times.
✓ Branch 1 taken 1845 times.
✓ Branch 2 taken 72696 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72696 times.
74541 if(action==swimming || IsSideSwim() || action == swimhit)
16435 {
16436 1845 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16437
16438
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1845 times.
✓ Branch 2 taken 1845 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✓ Branch 5 taken 1759 times.
✓ Branch 6 taken 1599 times.
✓ Branch 7 taken 246 times.
3604 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16439
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 1513 times.
3272 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16440 1513 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16441 246 info.setUnwalkable(true);
16442 1845 }
16443 else
16444 {
16445 72696 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16446
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 72683 times.
72696 if(x.getInt() & 7)
16447 13 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16448 else
16449 72683 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16450 }
16451
16452 74541 execute(info);
16453
16454
2/2
✓ Branch 0 taken 26646 times.
✓ Branch 1 taken 47895 times.
74541 if(!info.isUnwalkable())
16455 {
16456 47895 move(down);
16457 47895 return;
16458 }
16459
16460
4/4
✓ Branch 0 taken 25257 times.
✓ Branch 1 taken 1389 times.
✓ Branch 2 taken 1377 times.
✓ Branch 3 taken 23880 times.
26646 if(!DrunkLeft() && !DrunkRight())
16461 {
16462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23880 times.
23880 if(NO_GRIDLOCK)
16463 {
16464 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16465 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16466 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16467 {
16468 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16469 sprite::move((zfix)-1,(zfix)0);
16470 }
16471 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16472 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16473 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16474 {
16475 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16476 sprite::move((zfix)1,(zfix)0);
16477 }
16478 else
16479 {
16480 pushing=push+1;
16481 }
16482 }
16483 23880 else pushing=push+1;
16484
16485
2/4
✓ Branch 0 taken 23880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23880 times.
✗ Branch 3 not taken.
23880 if(charging==0 && spins==0)
16486 {
16487 23880 dir=down;
16488 23880 }
16489
16490
5/8
✓ Branch 0 taken 23712 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 23712 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23712 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 23712 times.
23880 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16491 {
16492 23712 herostep();
16493 23712 }
16494
16495 23880 return;
16496 }
16497 2766 else goto LEFTRIGHT_OLDMOVE;
16498 }
16499
16500 1947 return;
16501 }
16502
16503 LEFTRIGHT_OLDMOVE:
16504
16505
7/8
✓ Branch 0 taken 514262 times.
✓ Branch 1 taken 146145 times.
✓ Branch 2 taken 503531 times.
✓ Branch 3 taken 10731 times.
✓ Branch 4 taken 6868 times.
✓ Branch 5 taken 507394 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6868 times.
660407 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16506 {
16507 6868 return;
16508 }
16509
16510
2/2
✓ Branch 0 taken 92831 times.
✓ Branch 1 taken 560708 times.
653539 if(DrunkLeft())
16511 {
16512
9/14
✓ Branch 0 taken 1891 times.
✓ Branch 1 taken 90940 times.
✓ Branch 2 taken 1891 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1872 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 1872 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1872 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1872 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1872 times.
92831 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16513 {
16514
2/4
✓ Branch 0 taken 1872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1872 times.
1872 if(dir!=left && dir!=right)
16515 {
16516
4/4
✓ Branch 0 taken 1334 times.
✓ Branch 1 taken 538 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 746 times.
1872 if(yoff>2&&yoff<6)
16517 {
16518 746 move(dir);
16519 746 }
16520
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 538 times.
1126 else if(yoff>=6)
16521 {
16522 588 move(down);
16523 588 }
16524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 538 times.
538 else if(yoff>=1)
16525 {
16526 538 move(up);
16527 538 }
16528 1872 }
16529 else
16530 {
16531 if(yoff>=4)
16532 {
16533 move(down);
16534 }
16535 else if(yoff<4)
16536 {
16537 move(up);
16538 }
16539 }
16540 1872 }
16541 else
16542 {
16543 181918 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16544 90959 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16545
16546 90959 execute(info);
16547
16548
2/2
✓ Branch 0 taken 16747 times.
✓ Branch 1 taken 74212 times.
90959 if(!info.isUnwalkable())
16549 {
16550 74212 move(left);
16551 74212 return;
16552 }
16553
16554
4/4
✓ Branch 0 taken 16645 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 373 times.
✓ Branch 3 taken 16272 times.
16747 if(!DrunkUp() && !DrunkDown())
16555 {
16556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16272 times.
16272 if(NO_GRIDLOCK)
16557 {
16558 int32_t v1=bigHitbox?0:8;
16559 int32_t v2=bigHitbox?8:12;
16560
16561 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16562 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16563 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16564 {
16565 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16566 sprite::move((zfix)0,(zfix)-1);
16567 }
16568 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16569 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16570 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16571 {
16572 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16573 sprite::move((zfix)0,(zfix)1);
16574 }
16575 else
16576 {
16577 pushing=push+1;
16578 }
16579 }
16580 16272 else pushing=push+1;
16581
16582
2/4
✓ Branch 0 taken 16272 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16272 times.
16272 if(charging==0 && spins==0)
16583 {
16584 16272 dir=left;
16585 16272 }
16586
16587
5/8
✓ Branch 0 taken 16260 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 16260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16260 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16260 times.
16272 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16588 {
16589 16260 herostep();
16590 16260 }
16591
16592 16272 return;
16593 }
16594 }
16595
16596 2347 return;
16597 }
16598
16599
2/2
✓ Branch 0 taken 460310 times.
✓ Branch 1 taken 100398 times.
560708 if(DrunkRight())
16600 {
16601
9/14
✓ Branch 0 taken 1897 times.
✓ Branch 1 taken 98501 times.
✓ Branch 2 taken 1897 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1872 times.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 1872 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1872 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1872 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1872 times.
100398 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16602 {
16603
2/4
✓ Branch 0 taken 1872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1872 times.
1872 if(dir!=left && dir!=right)
16604 {
16605
4/4
✓ Branch 0 taken 1335 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 536 times.
✓ Branch 3 taken 799 times.
1872 if(yoff>2&&yoff<6)
16606 {
16607 799 move(dir);
16608 799 }
16609
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 537 times.
1073 else if(yoff>=6)
16610 {
16611 536 move(down);
16612 536 }
16613
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 else if(yoff>=1)
16614 {
16615 537 move(up);
16616 537 }
16617 1872 }
16618 else
16619 {
16620 if(yoff>=4)
16621 {
16622 move(down);
16623 }
16624 else if(yoff<4)
16625 {
16626 move(up);
16627 }
16628 }
16629 1872 }
16630 else
16631 {
16632 197052 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16633 98526 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16634
16635 98526 execute(info);
16636
16637
2/2
✓ Branch 0 taken 20688 times.
✓ Branch 1 taken 77838 times.
98526 if(!info.isUnwalkable())
16638 {
16639 77838 move(right);
16640 77838 return;
16641 }
16642
16643
4/4
✓ Branch 0 taken 20423 times.
✓ Branch 1 taken 265 times.
✓ Branch 2 taken 148 times.
✓ Branch 3 taken 20275 times.
20688 if(!DrunkUp() && !DrunkDown())
16644 {
16645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20275 times.
20275 if(NO_GRIDLOCK)
16646 {
16647 int32_t v1=bigHitbox?0:8;
16648 int32_t v2=bigHitbox?8:12;
16649
16650 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16651 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16652 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16653 {
16654 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16655 sprite::move((zfix)0,(zfix)-1);
16656 }
16657 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16658 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16659 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16660 {
16661 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16662 sprite::move((zfix)0,(zfix)1);
16663 }
16664 else
16665 {
16666 pushing=push+1;
16667 }
16668 }
16669 20275 else pushing=push+1;
16670
16671
2/4
✓ Branch 0 taken 20275 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20275 times.
20275 if(charging==0 && spins==0)
16672 {
16673 20275 dir=right;
16674 20275 }
16675
16676
5/8
✓ Branch 0 taken 20233 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 20233 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20233 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20233 times.
20275 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16677 {
16678 20233 herostep();
16679 20233 }
16680
16681 20275 return;
16682 }
16683 }
16684 2285 }
16685 }
16686 2344795 }
16687
16688 //solid ffc checking should probably be moved to here.
16689 1410705 void HeroClass::move(int32_t d2, int32_t forceRate)
16690 {
16691
4/6
✓ Branch 0 taken 1410523 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 1410523 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1410523 times.
1410705 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16692 182 return;
16693
16694
3/4
✓ Branch 0 taken 1403791 times.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1403791 times.
1410523 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
16695 {
16696 1403791 moveOld(d2);
16697 1403791 return;
16698 }
16699
16700
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13464 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
16701
5/6
✓ Branch 0 taken 4762 times.
✓ Branch 1 taken 1970 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 3402 times.
✓ Branch 4 taken 4762 times.
✗ Branch 5 not taken.
6732 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
16702 //!DIMITODO: add QR for slow combos under hero
16703
2/2
✓ Branch 0 taken 13464 times.
✓ Branch 1 taken 6732 times.
20196 for (int32_t i = 0; i <= 1; ++i)
16704 {
16705
2/2
✓ Branch 0 taken 12145 times.
✓ Branch 1 taken 1319 times.
13464 if(tmpscr2[i].valid!=0)
16706 {
16707
1/2
✓ Branch 0 taken 1319 times.
✗ Branch 1 not taken.
1319 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
16708 {
16709 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16710 }
16711 else
16712 {
16713
2/4
✓ Branch 0 taken 1319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1319 times.
✗ Branch 3 not taken.
1319 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16714 }
16715 1319 }
16716 13464 }
16717
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16718 6732 bool is_swimming = (action == swimming);
16719 6732 bool fastSwim = (zinit.hero_swim_speed>60);
16720 6732 zfix rate(steprate);
16721 6732 int32_t shieldid = getCurrentActiveShield();
16722
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(shieldid > -1)
16723 {
16724 itemdata const& shield = itemsbuf[shieldid];
16725 if(shield.flags & ITEM_FLAG10) //Change Speed flag
16726 {
16727 zfix perc = shield.misc7;
16728 perc /= 100;
16729 if(perc < 0)
16730 perc = (perc*-1)+1;
16731 rate = (rate * perc) + shield.misc8;
16732 }
16733 }
16734
16735 6732 zfix dx, dy;
16736 6732 zfix movepix(rate / 100);
16737 6732 zfix step(movepix);
16738 6732 zfix step_diag(movepix);
16739 6732 zfix up_step(game->get_sideswim_up() / -100.0);
16740 6732 zfix left_step(game->get_sideswim_side() / -100.0);
16741 6732 zfix right_step(game->get_sideswim_side() / 100.0);
16742 6732 zfix down_step(game->get_sideswim_down() / 100.0);
16743 6732 bool checkladder = false;
16744
16745
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(hero_newstep > movepix) hero_newstep = movepix;
16746
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
16747 //2/3 speed
16748
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✓ Branch 2 taken 6732 times.
✓ Branch 3 taken 6732 times.
✓ Branch 4 taken 6732 times.
✓ Branch 5 taken 6732 times.
6732 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
16749 {
16750 13464 step = ((step / 3.0) * 2);
16751 13464 step_diag = ((step_diag / 3.0) * 2);
16752 13464 up_step = ((up_step / 3.0) * 2);
16753 13464 left_step = ((left_step / 3.0) * 2);
16754 13464 right_step = ((right_step / 3.0) * 2);
16755 13464 down_step = ((down_step / 3.0) * 2);
16756 13464 }
16757 //1/2 speed
16758
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6732 times.
6732 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
16759 {
16760 step /= 2;
16761 step_diag /= 2;
16762 up_step /= 2;
16763 left_step /= 2;
16764 right_step /= 2;
16765 down_step /= 2;
16766 }
16767 //normal speed
16768 else
16769 {
16770 //no modification
16771 }
16772
16773
1/2
✓ Branch 0 taken 6732 times.
✗ Branch 1 not taken.
6732 if(diagonalMovement)
16774 {
16775 //zprint2("Player's X is %d, Y is %d\n", x, y);
16776
6/6
✓ Branch 0 taken 6058 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 5844 times.
✓ Branch 3 taken 214 times.
✓ Branch 4 taken 1143 times.
✓ Branch 5 taken 5375 times.
11801 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
16777
4/4
✓ Branch 0 taken 4085 times.
✓ Branch 1 taken 3871 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 2887 times.
214 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
16778 {
16779
2/4
✓ Branch 0 taken 837 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 837 times.
11587 if(hero_newstep > 0 && hero_newstep_diag > 0)
16780 {
16781 837 step = STEP_DIAGONAL(step);
16782 837 step_diag = STEP_DIAGONAL(step_diag);
16783 837 up_step = STEP_DIAGONAL(up_step);
16784 837 left_step = STEP_DIAGONAL(left_step);
16785 837 right_step = STEP_DIAGONAL(right_step);
16786 837 down_step = STEP_DIAGONAL(down_step);
16787 837 }
16788 837 }
16789
2/2
✓ Branch 0 taken 3131 times.
✓ Branch 1 taken 593 times.
3724 if(hero_newstep < step) step = hero_newstep; //handle collision
16790
2/2
✓ Branch 0 taken 3679 times.
✓ Branch 1 taken 45 times.
3724 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
16791
5/5
✓ Branch 0 taken 3008 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 757 times.
✓ Branch 3 taken 2183 times.
✓ Branch 4 taken 3118 times.
3724 switch(d2)
16792 {
16793 case up:
16794
3/3
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 93 times.
674 switch(shiftdir)
16795 {
16796 case left:
16797 227 dx = -step_diag;
16798
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 if (IsSideSwim()) dx = left_step;
16799 227 break;
16800 case right:
16801 93 dx = step_diag;
16802
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if (IsSideSwim()) dx = right_step;
16803 93 break;
16804 }
16805
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 339 times.
674 if(walkable)
16806 {
16807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if (!IsSideSwim()) dy = -step;
16808
1/2
✓ Branch 0 taken 339 times.
✗ Branch 1 not taken.
339 if (IsSideSwim())
16809 {
16810 dy = up_step;
16811 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16812 }
16813 339 }
16814 674 break;
16815 case down:
16816
3/3
✓ Branch 0 taken 613 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 83 times.
757 switch(shiftdir)
16817 {
16818 case left:
16819 61 dx = -step_diag;
16820
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if (IsSideSwim()) dx = left_step;
16821 61 break;
16822 case right:
16823 83 dx = step_diag;
16824
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if (IsSideSwim()) dx = right_step;
16825 83 break;
16826 }
16827
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 377 times.
757 if(walkable)
16828 {
16829 377 dy = step;
16830
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if (IsSideSwim()) dy = down_step;
16831 377 }
16832 757 break;
16833 case left:
16834
3/3
✓ Branch 0 taken 2098 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 45 times.
2183 switch(shiftdir)
16835 {
16836 case up:
16837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (!IsSideSwim()) dy = -step_diag;
16838
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (IsSideSwim())
16839 {
16840 dy = up_step;
16841 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16842 }
16843 40 break;
16844 case down:
16845 45 dy = step_diag;
16846
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if (IsSideSwim()) dy = down_step;
16847 45 break;
16848 }
16849
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 2117 times.
2183 if(walkable)
16850 {
16851 2117 dx = -step;
16852
1/2
✓ Branch 0 taken 2117 times.
✗ Branch 1 not taken.
2117 if (IsSideSwim()) dx = left_step;
16853 2117 }
16854 2183 break;
16855 case right:
16856
3/3
✓ Branch 0 taken 2830 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 96 times.
3118 switch(shiftdir)
16857 {
16858 case up:
16859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if (!IsSideSwim()) dy = -step_diag;
16860
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if (IsSideSwim())
16861 {
16862 dy = up_step;
16863 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16864 }
16865 192 break;
16866 case down:
16867 96 dy = step_diag;
16868
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if (IsSideSwim()) dy = down_step;
16869 96 break;
16870 }
16871
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 2915 times.
3118 if(walkable)
16872 {
16873 2915 dx = step;
16874
1/2
✓ Branch 0 taken 2915 times.
✗ Branch 1 not taken.
2915 if (IsSideSwim()) dx = right_step;
16875 2915 }
16876 3118 break;
16877 };
16878 9740 }
16879 else
16880 {
16881 if(hero_newstep < step) step = hero_newstep; //handle collision
16882 switch(d2)
16883 {
16884 case up:
16885 dy -= step;
16886 if (IsSideSwim()) dy = up_step;
16887 break;
16888 case down:
16889 dy += step;
16890 if (IsSideSwim()) dy = down_step;
16891 break;
16892 case left:
16893 dx -= step;
16894 if (IsSideSwim()) dx = left_step;
16895 break;
16896 case right:
16897 dx += step;
16898 if (IsSideSwim()) dx = right_step;
16899 break;
16900 };
16901 }
16902 9740 hero_newstep = movepix;
16903 9740 hero_newstep_diag = movepix;
16904
16905
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 9740 times.
✓ Branch 2 taken 6732 times.
✓ Branch 3 taken 3008 times.
✓ Branch 4 taken 6732 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6732 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6732 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
9740 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
16906 {
16907 6732 dir=d2;
16908 6732 }
16909
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 3008 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3008 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
16910 {
16911 dir = shiftdir;
16912 }
16913
1/2
✓ Branch 0 taken 9740 times.
✗ Branch 1 not taken.
9740 if(forceRate > -1)
16914 {
16915 checkladder = false;
16916 switch(dir)
16917 {
16918 case right:
16919 case r_up:
16920 case r_down:
16921 dx = zfix(forceRate) / 100;
16922 break;
16923 case left:
16924 case l_up:
16925 case l_down:
16926 dx = zfix(-forceRate) / 100;
16927 break;
16928 default:
16929 dx = 0;
16930 }
16931 switch(dir)
16932 {
16933 case down:
16934 case r_down:
16935 case l_down:
16936 dy = zfix(forceRate) / 100;
16937 break;
16938 case up:
16939 case r_up:
16940 case l_up:
16941 dy = zfix(-forceRate) / 100;
16942 break;
16943 default:
16944 dy = 0;
16945 }
16946 }
16947
4/4
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 8504 times.
✓ Branch 2 taken 745 times.
✓ Branch 3 taken 491 times.
9740 if(dx == 0 && dy == 0) return;
16948
5/8
✓ Branch 0 taken 6241 times.
✓ Branch 1 taken 3008 times.
✓ Branch 2 taken 6241 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6241 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6241 times.
9249 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16949 {
16950 6241 herostep();
16951
16952 //ack... don't walk if in midair! -DD
16953
11/14
✓ Branch 0 taken 6241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6241 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6195 times.
✓ Branch 5 taken 46 times.
✓ Branch 6 taken 6195 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4526 times.
✓ Branch 9 taken 1669 times.
✓ Branch 10 taken 1270 times.
✓ Branch 11 taken 3256 times.
✓ Branch 12 taken 268 times.
✓ Branch 13 taken 1002 times.
6241 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
16954 {
16955 5193 action=walking; FFCore.setHeroAction(walking);
16956 5193 }
16957
16958
2/2
✓ Branch 0 taken 5911 times.
✓ Branch 1 taken 330 times.
6241 if(++hero_count > (16*hero_animation_speed))
16959 330 hero_count=0;
16960 6241 }
16961
1/2
✓ Branch 0 taken 3008 times.
✗ Branch 1 not taken.
3008 else if(!(frame & 1))
16962 {
16963 herostep();
16964 }
16965
16966
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9249 times.
✓ Branch 2 taken 3008 times.
✓ Branch 3 taken 3008 times.
9249 if(charging==0 || attack!=wHammer)
16967 {
16968 12257 sprite::move(dx, dy);
16969 12257 WalkflagInfo info;
16970 12257 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
16971 12257 execute(info);
16972
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6241 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6241 times.
✗ Branch 7 not taken.
12257 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
16973 {
16974 if (game->get_sideswim_jump() != 0)
16975 {
16976 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
16977 sfx(WAV_ZN1SPLASH,(int32_t)x);
16978 hopclk = 0;
16979 if (charging || spins) action = attacking;
16980 else action = none;
16981 }
16982 else
16983 {
16984 sprite::move(zfix(0), zfix(-1*dy));
16985 }
16986 }
16987 6241 }
16988 1413713 }
16989
16990 1403791 void HeroClass::moveOld(int32_t d2)
16991 {
16992 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
16993 static bool totalskip = false;
16994
16995
3/6
✓ Branch 0 taken 1403791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1403791 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1403791 times.
1403791 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16996 return;
16997
16998 1403791 int32_t dx=0,dy=0;
16999 1403791 int32_t xstep=lsteps[x.getInt()&7];
17000 1403791 int32_t ystep=lsteps[y.getInt()&7];
17001 1403791 int32_t z3skip=0;
17002 1403791 int32_t z3diagskip=0;
17003
3/6
✓ Branch 0 taken 35584 times.
✓ Branch 1 taken 1368207 times.
✓ Branch 2 taken 35584 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2771998 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
17004
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1368207 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1368207 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
17005
1/2
✓ Branch 0 taken 1403791 times.
✗ Branch 1 not taken.
1403791 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
17006 1403791 bool is_swimming = (action == swimming);
17007
17008 //slow walk combo, or charging, moves at 2/3 speed
17009 if(
17010
4/4
✓ Branch 0 taken 1393329 times.
✓ Branch 1 taken 10462 times.
✓ Branch 2 taken 35584 times.
✓ Branch 3 taken 1357745 times.
1414253 (!is_swimming && (slowcharging ^ slowcombo))||
17011
2/2
✓ Branch 0 taken 10462 times.
✓ Branch 1 taken 1357745 times.
1368207 (is_swimming && (zinit.hero_swim_speed>60))
17012 )
17013 {
17014 46046 totalskip = false;
17015
17016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46046 times.
46046 if(diagonalMovement)
17017 {
17018 skipstep=(skipstep+1)%6;
17019
17020 if(skipstep%2==0) z3skip=1;
17021 else z3skip=0;
17022
17023 if(skipstep%3==0) z3diagskip=1;
17024 else z3diagskip=0;
17025 }
17026 else
17027 {
17028
2/2
✓ Branch 0 taken 33040 times.
✓ Branch 1 taken 13006 times.
46046 if(d2<left)
17029 {
17030
2/2
✓ Branch 0 taken 19895 times.
✓ Branch 1 taken 13145 times.
33040 if(ystep>1)
17031 {
17032 13145 skipstep^=1;
17033 13145 ystep=skipstep;
17034 13145 }
17035 33040 }
17036 else
17037 {
17038
2/2
✓ Branch 0 taken 7852 times.
✓ Branch 1 taken 5154 times.
13006 if(xstep>1)
17039 {
17040 5154 skipstep^=1;
17041 5154 xstep=skipstep;
17042 5154 }
17043 }
17044 }
17045 46046 }
17046 // else if(is_swimming || (slowcharging && slowcombo))
17047 else if(
17048
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357745 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357745 (is_swimming && (zinit.hero_swim_speed<60))||
17049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1357745 times.
1357745 (slowcharging && slowcombo)
17050 )
17051 {
17052 //swimming, or charging on a slow combo, moves at 1/2 speed
17053 totalskip = !totalskip;
17054
17055 if(diagonalMovement)
17056 {
17057 skipstep=0;
17058 }
17059 }
17060 else
17061 {
17062 1357745 totalskip = false;
17063
17064
1/2
✓ Branch 0 taken 1357745 times.
✗ Branch 1 not taken.
1357745 if(diagonalMovement)
17065 {
17066 skipstep=0;
17067 }
17068 }
17069
17070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1403791 times.
1403791 if(!totalskip)
17071 {
17072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1403791 times.
1403791 if(diagonalMovement)
17073 {
17074 switch(d2)
17075 {
17076 case up:
17077 if(shiftdir==left)
17078 {
17079 if(walkable)
17080 {
17081 dy-=1-z3diagskip;
17082 dx-=1-z3diagskip;
17083 z3step=2;
17084 }
17085 else
17086 {
17087 dx-=1-z3diagskip;
17088 z3step=2;
17089 }
17090 }
17091 else if(shiftdir==right)
17092 {
17093 if(walkable)
17094 {
17095 dy-=1-z3diagskip;
17096 dx+=1-z3diagskip;
17097 z3step=2;
17098 }
17099 else
17100 {
17101 dx+=1-z3diagskip;
17102 z3step=2;
17103 }
17104 }
17105 else
17106 {
17107 if(walkable)
17108 {
17109 dy-=z3step-z3skip;
17110 z3step=(z3step%2)+1;
17111 }
17112 }
17113
17114 break;
17115
17116 case down:
17117 if(shiftdir==left)
17118 {
17119 if(walkable)
17120 {
17121 dy+=1-z3diagskip;
17122 dx-=1-z3diagskip;
17123 z3step=2;
17124 }
17125 else
17126 {
17127 dx-=1-z3diagskip;
17128 z3step=2;
17129 }
17130 }
17131 else if(shiftdir==right)
17132 {
17133 if(walkable)
17134 {
17135 dy+=1-z3diagskip;
17136 dx+=1-z3diagskip;
17137 z3step=2;
17138 }
17139 else
17140 {
17141 dx+=1-z3diagskip;
17142 z3step=2;
17143 }
17144 }
17145 else
17146 {
17147 if(walkable)
17148 {
17149 dy+=z3step-z3skip;
17150 z3step=(z3step%2)+1;
17151 }
17152 }
17153
17154 break;
17155
17156 case right:
17157 if(shiftdir==up)
17158 {
17159 if(walkable)
17160 {
17161 dy-=1-z3diagskip;
17162 dx+=1-z3diagskip;
17163 z3step=2;
17164 }
17165 else
17166 {
17167 dy-=1-z3diagskip;
17168 z3step=2;
17169 }
17170 }
17171 else if(shiftdir==down)
17172 {
17173 if(walkable)
17174 {
17175 dy+=1-z3diagskip;
17176 dx+=1-z3diagskip;
17177 z3step=2;
17178 }
17179 else
17180 {
17181 dy+=1-z3diagskip;
17182 z3step=2;
17183 }
17184 }
17185 else
17186 {
17187 if(walkable)
17188 {
17189 dx+=z3step-z3skip;
17190 z3step=(z3step%2)+1;
17191 }
17192 }
17193
17194 break;
17195
17196 case left:
17197 if(shiftdir==up)
17198 {
17199 if(walkable)
17200 {
17201 dy-=1-z3diagskip;
17202 dx-=1-z3diagskip;
17203 z3step=2;
17204 }
17205 else
17206 {
17207 dy-=1-z3diagskip;
17208 z3step=2;
17209 }
17210 }
17211 else if(shiftdir==down)
17212 {
17213 if(walkable)
17214 {
17215 dy+=1-z3diagskip;
17216 dx-=1-z3diagskip;
17217 z3step=2;
17218 }
17219 else
17220 {
17221 dy+=1-z3diagskip;
17222 z3step=2;
17223 }
17224 }
17225 else
17226 {
17227 if(walkable)
17228 {
17229 dx-=z3step-z3skip;
17230 z3step=(z3step%2)+1;
17231 }
17232 }
17233
17234 break;
17235 }
17236 }
17237 else
17238 {
17239
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 336158 times.
✓ Branch 2 taken 264737 times.
✓ Branch 3 taken 388659 times.
✓ Branch 4 taken 414237 times.
1403791 switch(d2)
17240 {
17241 case up:
17242
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 336158 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
336158 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
17243
17244 336158 break;
17245
17246 case down:
17247
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 264737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
264737 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
17248
17249 264737 break;
17250
17251 case left:
17252 388659 dx-=xstep;
17253 388659 break;
17254
17255 case right:
17256 414237 dx+=xstep;
17257 414237 break;
17258 }
17259 }
17260 1403791 }
17261
17262
5/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1403791 times.
✓ Branch 2 taken 1403791 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1403791 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1403791 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1403791 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1403791 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
17263 {
17264 1403791 dir=d2;
17265 1403791 }
17266 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
17267 {
17268 dir = shiftdir;
17269 }
17270
17271
3/4
✓ Branch 0 taken 1393329 times.
✓ Branch 1 taken 10462 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1393329 times.
1403791 if(action != swimming && !IsSideSwim())
17272 {
17273 1393329 herostep();
17274
17275 //ack... don't walk if in midair! -DD
17276
5/14
✓ Branch 0 taken 1393329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1393329 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1393329 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1393329 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1393329 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1393329 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
17277 {
17278 1393329 action=walking; FFCore.setHeroAction(walking);
17279 1393329 }
17280
17281
2/2
✓ Branch 0 taken 1319260 times.
✓ Branch 1 taken 74069 times.
1393329 if(++hero_count > (16*hero_animation_speed))
17282 74069 hero_count=0;
17283 1393329 }
17284
2/2
✓ Branch 0 taken 5230 times.
✓ Branch 1 taken 5232 times.
10462 else if(!(frame & 1))
17285 {
17286 5232 herostep();
17287 5232 }
17288
17289
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1403791 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1403791 if(charging==0 || attack!=wHammer)
17290 {
17291 1403791 sprite::move((zfix)dx,(zfix)dy);
17292 1403791 }
17293 1403791 }
17294
17295 5554821 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
17296 {
17297 5554821 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
17298 }
17299 5554821 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
17300 {
17301 5554821 WalkflagInfo ret;
17302
17303 5554821 wx = vbound(wx, -1, 256);
17304 5554821 wy = vbound(wy, -1, 176);
17305
17306
7/8
✓ Branch 0 taken 5549449 times.
✓ Branch 1 taken 5372 times.
✓ Branch 2 taken 5543963 times.
✓ Branch 3 taken 5486 times.
✓ Branch 4 taken 5543963 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 660 times.
✓ Branch 7 taken 5543303 times.
5554821 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
17307 {
17308 11518 ret.setUnwalkable(false);
17309 11518 return ret;
17310 }
17311
17312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5543303 times.
5543303 if(toogam)
17313 {
17314 ret.setUnwalkable(false);
17315 return ret;
17316 }
17317
17318
4/4
✓ Branch 0 taken 99868 times.
✓ Branch 1 taken 5443435 times.
✓ Branch 2 taken 99582 times.
✓ Branch 3 taken 286 times.
5543303 if(blockpath && wy<(bigHitbox?80:88))
17319 {
17320 286 ret.setUnwalkable(true);
17321 286 return ret;
17322 }
17323
17324
4/4
✓ Branch 0 taken 39314 times.
✓ Branch 1 taken 5503703 times.
✓ Branch 2 taken 30579 times.
✓ Branch 3 taken 8735 times.
5543017 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
17325 {
17326 8735 ret.setUnwalkable(true);
17327 8735 return ret;
17328 }
17329
17330
2/2
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 5531838 times.
5534282 if (collide_object(wx, wy,1, 1))
17331 {
17332 2444 ret.setUnwalkable(true);
17333 2444 return ret;
17334 }
17335
17336
14/20
✓ Branch 0 taken 4147693 times.
✓ Branch 1 taken 1384145 times.
✓ Branch 2 taken 3966256 times.
✓ Branch 3 taken 181437 times.
✓ Branch 4 taken 3854412 times.
✓ Branch 5 taken 111844 times.
✓ Branch 6 taken 111844 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 111844 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 58858 times.
✓ Branch 13 taken 52986 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 52986 times.
✓ Branch 16 taken 52986 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6250 times.
✓ Branch 19 taken 5525588 times.
5602098 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17337
2/2
✓ Branch 0 taken 11402 times.
✓ Branch 1 taken 41584 times.
111844 && !get_bit(quest_rules,qr_FREEFORM))
17338 {
17339 6250 ret.setUnwalkable(true);
17340 6250 return ret;
17341 }
17342
17343
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5525588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5525588 times.
5525588 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
17344
17345
6/6
✓ Branch 0 taken 4141443 times.
✓ Branch 1 taken 1384145 times.
✓ Branch 2 taken 3960006 times.
✓ Branch 3 taken 181437 times.
✓ Branch 4 taken 1221793 times.
✓ Branch 5 taken 2738213 times.
5525588 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17346 {
17347
2/4
✓ Branch 0 taken 2738213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2738213 times.
2738213 if((diagonalMovement||NO_GRIDLOCK))
17348 {
17349 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
17350
17351 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
17352 }
17353 2738213 }
17354 //All problems related to exiting water are probably here. -Z
17355
3/4
✓ Branch 0 taken 5463217 times.
✓ Branch 1 taken 62371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5463217 times.
5525588 if(action==swimming || IsSideSwim())
17356 {
17357
2/2
✓ Branch 0 taken 61316 times.
✓ Branch 1 taken 1055 times.
62371 if(!wf)
17358 {
17359 1055 bool isthissolid = false;
17360
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1055 times.
✓ Branch 4 taken 46 times.
✓ Branch 5 taken 1009 times.
1101 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17361
4/6
✓ Branch 0 taken 1009 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
1055 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17362
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
46 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17363
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
1055 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
17364 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17365
17366
17367
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 951 times.
2110 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
17368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
17369 {
17370 //Check for out of bounds for swimming
17371 104 bool changehop = true;
17372
17373
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if((diagonalMovement||NO_GRIDLOCK))
17374 {
17375 if(wx<0||wy<0)
17376 changehop = false;
17377 else if(wx>248)
17378 changehop = false;
17379 else if(wx>240&&cnt==2)
17380 changehop = false;
17381 else if(wy>168)
17382 changehop = false;
17383 }
17384
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
17385 //This may be where the hang-up for exiting water exists. -Z
17386 // hop out of the water
17387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(changehop)
17388 104 ret.setHopClk(1);
17389 104 }
17390 else
17391 {
17392
5/6
✓ Branch 0 taken 951 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 527 times.
✓ Branch 3 taken 424 times.
✓ Branch 4 taken 424 times.
✓ Branch 5 taken 103 times.
951 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
17393 {
17394 //int32_t vx=((int32_t)x+4)&0xFFF8;
17395 //int32_t vy=((int32_t)y+4)&0xFFF8;
17396
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 487 times.
527 if(d2==left)
17397 {
17398
2/4
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
80 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
17399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
17400
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
40 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17401
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
40 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17402 {
17403 40 ret.setHopDir(d2);
17404 40 ret.setIlswim(true);
17405 40 }
17406 else ret.setIlswim(false);
17407 40 }
17408
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 59 times.
487 else if(d2==right)
17409 {
17410
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 396 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 396 times.
460 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
17411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
17412
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
32 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17413
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17414 {
17415 32 ret.setHopDir(d2);
17416 32 ret.setIlswim(true);
17417 32 }
17418 396 else ret.setIlswim(false);
17419 428 }
17420
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 4 times.
59 else if(d2==up)
17421 {
17422
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
8 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
17423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
17424
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17425
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17426 {
17427 4 ret.setHopDir(d2);
17428 4 ret.setIlswim(true);
17429 4 }
17430 else ret.setIlswim(false);
17431 4 }
17432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 else if(d2==down)
17433 {
17434
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 45 times.
65 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
17435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
17436
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
10 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
17437
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
17438 {
17439 10 ret.setHopDir(d2);
17440 10 ret.setIlswim(true);
17441 10 }
17442 45 else ret.setIlswim(false);
17443 55 }
17444 527 }
17445
17446
2/4
✓ Branch 0 taken 951 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 951 times.
951 if(wx<0||wy<0);
17447
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 339 times.
951 else if(wx>248);
17448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
339 else if(wx>240&&cnt==2);
17449
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 294 times.
339 else if(wy>168);
17450
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17451 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
17452
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 276 times.
294 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17453 {
17454 18 ret.setUnwalkable(false);
17455 18 return ret;
17456 }
17457 else
17458 {
17459 276 ret.setUnwalkable(true);
17460 276 return ret;
17461 }
17462 }
17463 761 }
17464 else
17465 {
17466 61316 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17467 61316 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
17468
17469
8/8
✓ Branch 0 taken 58496 times.
✓ Branch 1 taken 2820 times.
✓ Branch 2 taken 57836 times.
✓ Branch 3 taken 660 times.
✓ Branch 4 taken 2820 times.
✓ Branch 5 taken 660 times.
✓ Branch 6 taken 2518 times.
✓ Branch 7 taken 302 times.
61316 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17470 {
17471 60354 ret.setUnwalkable(false);
17472 60354 return ret;
17473 }
17474 }
17475 1723 }
17476
2/2
✓ Branch 0 taken 121900 times.
✓ Branch 1 taken 5341317 times.
5463217 else if(ladderx+laddery) // ladder is being used
17477 {
17478
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 121900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
121900 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
17479
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 121900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
121900 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
17480
17481
2/4
✓ Branch 0 taken 121900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121900 times.
121900 if((diagonalMovement||NO_GRIDLOCK))
17482 {
17483 if(ladderdir==up)
17484 {
17485 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17486 {
17487 bool temp = false;
17488
17489 if(!(abs(lx-(ladderx+8))<=8))
17490 temp = true;
17491
17492 if(cnt==2)
17493 if(!(abs((lx+8)-(ladderx+8))<=8))
17494 temp=true;
17495
17496 if(!temp)
17497 {
17498 ret.setUnwalkable(false);
17499 return ret;
17500 }
17501
17502 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17503 {
17504 ret.setUnwalkable(true);
17505 return ret;
17506 }
17507 }
17508 }
17509 else
17510 {
17511 if(abs(lx-(ladderx+8))<=8)
17512 {
17513 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17514 {
17515 ret.setUnwalkable(false);
17516 return ret;
17517 }
17518
17519 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17520 {
17521 ret.setUnwalkable(true);
17522 return ret;
17523 }
17524
17525 if((abs(ly-laddery+8)<=8) && d2<=down)
17526 {
17527 ret.setUnwalkable(false);
17528 return ret;
17529 }
17530 }
17531 }
17532 } // diagonalMovement
17533 else
17534 {
17535
2/2
✓ Branch 0 taken 74377 times.
✓ Branch 1 taken 47523 times.
121900 if((d2&2)==ladderdir) // same direction
17536 {
17537
3/3
✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 66035 times.
✓ Branch 2 taken 4016 times.
74377 switch(d2)
17538 {
17539 case up:
17540
2/2
✓ Branch 0 taken 2731 times.
✓ Branch 1 taken 1285 times.
4016 if(y.getInt()<=laddery)
17541 {
17542
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2731 times.
✓ Branch 4 taken 194 times.
✓ Branch 5 taken 2537 times.
5268 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
17543
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2537 times.
2537 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
17544 2731 return ret;
17545
17546 }
17547
17548 [[fallthrough]];
17549 case down:
17550
2/2
✓ Branch 0 taken 3022 times.
✓ Branch 1 taken 2589 times.
5611 if((wy&0xF0)==laddery)
17551 {
17552 3022 ret.setUnwalkable(false);
17553 3022 return ret;
17554 }
17555
17556 2589 break;
17557
17558 default:
17559
2/2
✓ Branch 0 taken 27043 times.
✓ Branch 1 taken 38992 times.
66035 if((wx&0xF0)==ladderx)
17560 {
17561 27043 ret.setUnwalkable(false);
17562 27043 return ret;
17563 }
17564 38992 }
17565
17566
2/2
✓ Branch 0 taken 2589 times.
✓ Branch 1 taken 38992 times.
41581 if(d2<=down)
17567 {
17568
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2589 times.
✓ Branch 2 taken 2589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 2537 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2537 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2537 times.
2589 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
17569 2589 return ret;
17570 }
17571
17572
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 38992 times.
✓ Branch 2 taken 38992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5640 times.
✓ Branch 5 taken 33352 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 33352 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 33352 times.
38992 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
17573 38992 return ret;
17574 }
17575
17576 // different dir
17577
2/8
✓ Branch 0 taken 47523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47523 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
47523 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
17578 {
17579 47523 ret.setUnwalkable(true);
17580 47523 return ret;
17581 }
17582
17583 if(wy>=laddery && wy<=laddery+16 && d2<=down)
17584 {
17585 ret.setUnwalkable(false);
17586 return ret;
17587 }
17588 }
17589 }
17590
6/6
✓ Branch 0 taken 4746456 times.
✓ Branch 1 taken 594861 times.
✓ Branch 2 taken 4728676 times.
✓ Branch 3 taken 17780 times.
✓ Branch 4 taken 7127 times.
✓ Branch 5 taken 4721549 times.
5341317 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17591 {
17592 // see if it's a good spot for the ladder or for swimming
17593
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 619768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619768 times.
619768 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17594
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 619768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619768 times.
619768 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
17595
17596
2/2
✓ Branch 0 taken 25283 times.
✓ Branch 1 taken 594485 times.
619768 if(get_bit(quest_rules, qr_DROWN))
17597 {
17598 // Drowning changes the following attributes:
17599 // * Dangerous water is also walkable, so ignore the previous
17600 // definitions of unwalkablex and unwalkablex8.
17601 // * Instead, prevent the ladder from being used in the
17602 // one frame where Hero has landed on water before drowning.
17603 25283 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17604 25283 }
17605
17606 // check if he can swim
17607
4/6
✓ Branch 0 taken 82546 times.
✓ Branch 1 taken 537222 times.
✓ Branch 2 taken 82546 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 82546 times.
619768 if(current_item(itype_flippers) && z==0 && fakez==0)
17608 {
17609 82546 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17610 82546 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
17611
2/6
✓ Branch 0 taken 82546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82546 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82546 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17612 {
17613 //ladder ignores water combos that are now walkable thanks to flippers -DD
17614
2/2
✓ Branch 0 taken 662 times.
✓ Branch 1 taken 81884 times.
82546 unwalkablex = unwalkablex && (!wtrx);
17615
2/2
✓ Branch 0 taken 76867 times.
✓ Branch 1 taken 5679 times.
82546 unwalkablex8 = unwalkablex8 && (!wtrx8);
17616
17617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82546 times.
82546 if(landswim >= 22)
17618 {
17619 ret.setHopClk(2);
17620 ret.setUnwalkable(false);
17621 return ret;
17622 }
17623
8/8
✓ Branch 0 taken 76201 times.
✓ Branch 1 taken 6345 times.
✓ Branch 2 taken 520 times.
✓ Branch 3 taken 75681 times.
✓ Branch 4 taken 6345 times.
✓ Branch 5 taken 75681 times.
✓ Branch 6 taken 15 times.
✓ Branch 7 taken 6330 times.
82546 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17624 {
17625
2/4
✓ Branch 0 taken 535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 535 times.
535 if(!(diagonalMovement||NO_GRIDLOCK))
17626 {
17627 535 ret.setHopClk(2);
17628
17629
2/4
✓ Branch 0 taken 535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 535 times.
535 if(charging || spins>5)
17630 {
17631 //if Hero is charging, he might be facing the wrong direction (we want him to
17632 //hop into the water, not in the facing direction)
17633 ret.setDir(d2);
17634 //moreover Hero can't charge in the water -DD
17635 ret.setChargeAttack();
17636 }
17637
17638 535 ret.setUnwalkable(false);
17639 535 return ret;
17640 }
17641 else if(dir==d2)
17642 {
17643 ret.setIlswim(true);
17644 ladderx = 0;
17645 laddery = 0;
17646 }
17647 }
17648 82011 }
17649 82011 }
17650
17651 // check if he can use the ladder
17652 // "Allow Ladder Anywhere" is toggled by fLADDER
17653
2/2
✓ Branch 0 taken 217160 times.
✓ Branch 1 taken 402073 times.
619233 if(can_deploy_ladder())
17654 // laddersetup
17655 {
17656 // Check if there's water to use the ladder over
17657 402073 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
17658 402073 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
17659 402073 int32_t ldrid = current_item_id(itype_ladder);
17660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402073 times.
402073 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17661
17662
4/4
✓ Branch 0 taken 395997 times.
✓ Branch 1 taken 6076 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 395981 times.
402073 if(wtrx || wtrx8)
17663 {
17664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6092 times.
6092 if(isSideViewHero())
17665 {
17666 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17667 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17668 }
17669 // * walk on half-water using the ladder instead of using flippers.
17670 // * otherwise, walk on ladder(+hookshot) combos.
17671
3/8
✓ Branch 0 taken 377 times.
✓ Branch 1 taken 5715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 377 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6092 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
17672 {
17673
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17674 {
17675 //if Hero could swim on a tile instead of using the ladder,
17676 //refuse to use the ladder to step over that tile. -DD
17677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
17678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
17679 377 }
17680 377 }
17681 6092 }
17682 else
17683 {
17684 // No water; check other things
17685
17686 //Check pits
17687
1/2
✓ Branch 0 taken 395981 times.
✗ Branch 1 not taken.
395981 if(ladderpits)
17688 {
17689 int32_t pit_cmb = getpitfall(wx,wy);
17690 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17691 pit_cmb = getpitfall(x+8,wy);
17692 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17693 }
17694
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 395981 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
395981 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17695 {
17696 395981 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
17697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395981 times.
395981 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17698 395981 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
17699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395981 times.
395981 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17700 395981 }
17701 }
17702
17703
2/2
✓ Branch 0 taken 804146 times.
✓ Branch 1 taken 402073 times.
1206219 for (int32_t i = 0; i <= 1; ++i)
17704 {
17705
2/2
✓ Branch 0 taken 666812 times.
✓ Branch 1 taken 137334 times.
804146 if(tmpscr2[i].valid!=0)
17706 {
17707
1/2
✓ Branch 0 taken 137334 times.
✗ Branch 1 not taken.
137334 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17708 {
17709
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 137334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
137334 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17710
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 137334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
137334 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17711 137334 }
17712 else
17713 {
17714 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17715 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17716 }
17717 137334 }
17718 804146 }
17719
1/2
✓ Branch 0 taken 402073 times.
✗ Branch 1 not taken.
402073 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
17720
17721
2/4
✓ Branch 0 taken 402073 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 402073 times.
402073 if((diagonalMovement||NO_GRIDLOCK))
17722 {
17723 if(d2==dir)
17724 {
17725 int32_t c = walkwater ? 0:8;
17726 int32_t b = walkwater ? 8:0;
17727
17728 if(d2>=left)
17729 {
17730 // If the difference between wy and y is small enough
17731 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
17732 {
17733 // Don't activate the ladder if it would be entirely
17734 // over water and Hero has the flippers. This isn't
17735 // a good way to do this, but it's too risky
17736 // to make big changes to this stuff.
17737 bool deployLadder=true;
17738 int32_t lx=wx&0xF0;
17739 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17740 {
17741 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17742 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17743 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17744 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17745 deployLadder=false;
17746 }
17747 if(deployLadder)
17748 {
17749 ladderx = wx&0xF0;
17750 laddery = y;
17751 ladderdir = left;
17752 ladderstart = d2;
17753 ret.setUnwalkable(laddery!=y.getInt());
17754 return ret;
17755 }
17756 }
17757 }
17758 else if(d2<=down)
17759 {
17760 // If the difference between wx and x is small enough
17761 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
17762 {
17763 ladderx = x;
17764 laddery = wy&0xF0;
17765 ladderdir = up;
17766 ladderstart = d2;
17767 ret.setUnwalkable(ladderx!=x.getInt());
17768 return ret;
17769 }
17770
17771 if(cnt==2)
17772 {
17773 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17774 {
17775 ladderx = x;
17776 laddery = wy&0xF0;
17777 ladderdir = up;
17778 ladderstart = d2;
17779 ret.setUnwalkable(ladderx!=x.getInt());
17780 return ret;
17781 }
17782 }
17783 }
17784 }
17785 }
17786 else
17787 {
17788
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 402073 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 402073 times.
✓ Branch 4 taken 4016 times.
✓ Branch 5 taken 398057 times.
402073 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
17789
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 402073 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 402073 times.
✓ Branch 4 taken 372289 times.
✓ Branch 5 taken 29784 times.
402073 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
17790
17791
2/2
✓ Branch 0 taken 368433 times.
✓ Branch 1 taken 33640 times.
402089 if((d2>=left && wtrx)
17792 // Deploy the ladder vertically even if Hero is only half on water.
17793
8/8
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 361653 times.
✓ Branch 2 taken 33640 times.
✓ Branch 3 taken 361653 times.
✓ Branch 4 taken 433 times.
✓ Branch 5 taken 33207 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 33624 times.
402073 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
17794 {
17795
4/4
✓ Branch 0 taken 6606 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 6331 times.
6780 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
17796 449 ladderdir = up;
17797 else
17798 6331 ladderdir = left;
17799
17800
2/2
✓ Branch 0 taken 6331 times.
✓ Branch 1 taken 449 times.
6780 if(ladderdir==up)
17801 {
17802 449 ladderx = x.getInt()&0xF8;
17803 449 laddery = wy&0xF0;
17804 449 }
17805 else
17806 {
17807 6331 ladderx = wx&0xF0;
17808 6331 laddery = y.getInt()&0xF8;
17809 }
17810
17811 6780 ret.setUnwalkable(false);
17812 6780 return ret;
17813 }
17814 }
17815 395293 }
17816 612453 }
17817
17818 5335725 ret.setUnwalkable(wf);
17819 5335725 return ret;
17820 5554821 }
17821
17822 // Only checks for moving blocks. Apparently this is a thing we need.
17823 625472 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
17824 {
17825 625472 HeroClass::WalkflagInfo ret;
17826
2/2
✓ Branch 0 taken 5318 times.
✓ Branch 1 taken 620154 times.
625472 if (!blockmoving) //Without this, weird swimming behaviors happen.
17827 {
17828 620154 ret.setFlags(~1);
17829 620154 ret.setHopDir(-1);
17830 620154 }
17831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625472 times.
625472 if(toogam) return ret;
17832
2/2
✓ Branch 0 taken 620154 times.
✓ Branch 1 taken 5318 times.
625472 if (blockmoving)
17833 5318 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
17834
2/2
✓ Branch 0 taken 625284 times.
✓ Branch 1 taken 188 times.
625472 if (collide_object(wx, wy,1, 1))
17835 188 ret.setUnwalkable(true);
17836 625472 return ret;
17837 625472 }
17838
17839 2436433 bool HeroClass::checksoliddamage()
17840 {
17841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2436433 times.
2436433 if(toogam) return false;
17842
17843
2/4
✓ Branch 0 taken 2436433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2436433 times.
2436433 if(z!=0||fakez!=0) return false;
17844 2436433 int32_t bx = x.getInt();
17845 2436433 int32_t by = y.getInt();
17846 2436433 int32_t initk = 0;
17847
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 599210 times.
✓ Branch 2 taken 478637 times.
✓ Branch 3 taken 666577 times.
✓ Branch 4 taken 692009 times.
2436433 switch(dir)
17848 {
17849 case up:
17850
17851 599210 by-=bigHitbox ? 4 : -4;
17852
17853
1/2
✓ Branch 0 taken 599210 times.
✗ Branch 1 not taken.
599210 if(by<0)
17854 {
17855 return false;
17856 }
17857 599210 break;
17858
17859 case down:
17860
17861 478637 by+=20;
17862
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 475692 times.
478637 if(by>175)
17863 {
17864 2945 return false;
17865 }
17866
17867 475692 break;
17868
17869 case left:
17870 666577 bx-=4;
17871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 666577 times.
666577 if (!bigHitbox)
17872 {
17873 666577 by+=8;
17874 666577 initk = 1;
17875 666577 }
17876
2/2
✓ Branch 0 taken 664135 times.
✓ Branch 1 taken 2442 times.
666577 if(bx<0)
17877 {
17878 2442 return false;
17879 }
17880
17881 664135 break;
17882
17883 case right:
17884
17885 692009 bx+=20;
17886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692009 times.
692009 if (!bigHitbox)
17887 {
17888 692009 by+=8;
17889 692009 initk = 1;
17890 692009 }
17891
2/2
✓ Branch 0 taken 3741 times.
✓ Branch 1 taken 688268 times.
692009 if(bx>255)
17892 {
17893 3741 return false;
17894 }
17895
17896 688268 break;
17897 }
17898 2427305 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
17899 2427305 int32_t t = cmb.type;
17900
1/2
✓ Branch 0 taken 2427305 times.
✗ Branch 1 not taken.
2427305 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17901 t = cNONE;
17902 2427305 int32_t initbx = bx;
17903 2427305 int32_t initby = by;
17904
17905 // Unlike push blocks, damage combos should be tested on layers 2 and under
17906
2/2
✓ Branch 0 taken 3967585 times.
✓ Branch 1 taken 2427304 times.
6394889 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
17907 {
17908 3967585 bx = initbx;
17909 3967585 by = initby;
17910
2/2
✓ Branch 0 taken 9735843 times.
✓ Branch 1 taken 3967584 times.
13703427 for (int32_t k = initk; k <= 2; k++)
17911 {
17912 9735843 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
17913 9735843 t = cmb.type;
17914
1/2
✓ Branch 0 taken 9735843 times.
✗ Branch 1 not taken.
9735843 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17915 t = cNONE;
17916 // Solid damage combos use pushing>0, hence the code is here.
17917
10/10
✓ Branch 0 taken 48694 times.
✓ Branch 1 taken 9687149 times.
✓ Branch 2 taken 25759 times.
✓ Branch 3 taken 22935 times.
✓ Branch 4 taken 24697 times.
✓ Branch 5 taken 1062 times.
✓ Branch 6 taken 2736 times.
✓ Branch 7 taken 21961 times.
✓ Branch 8 taken 81 times.
✓ Branch 9 taken 2655 times.
9735843 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
17918 {
17919
10/18
✓ Branch 0 taken 9730072 times.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054 times.
✓ Branch 4 taken 2054 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 125 times.
✓ Branch 7 taken 1929 times.
✓ Branch 8 taken 34 times.
✓ Branch 9 taken 91 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 34 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 9732126 times.
✗ Branch 17 not taken.
9732126 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
17920 {
17921 // Bite Hero
17922 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
17923 }
17924 9732126 }
17925
3/4
✓ Branch 0 taken 25759 times.
✓ Branch 1 taken 9710084 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25249 times.
9761092 if(isSideViewHero() && // Check for sideview damage combos
17926
3/4
✓ Branch 0 taken 25249 times.
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 25249 times.
✗ Branch 3 not taken.
25759 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
17927 {
17928
1/2
✓ Branch 0 taken 25249 times.
✗ Branch 1 not taken.
25249 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
17929 {
17930
5/6
✓ Branch 0 taken 25249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 25018 times.
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 159 times.
25249 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
17931 {
17932
4/4
✓ Branch 0 taken 25083 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 25089 times.
✓ Branch 3 taken 1 times.
25090 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
17933 {
17934
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
17935 }
17936 25089 }
17937
1/2
✓ Branch 0 taken 25248 times.
✗ Branch 1 not taken.
25248 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
17938 25248 }
17939 else
17940 {
17941 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
17942 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
17943 {
17944 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
17945 x+8+(zc_max(tmpscr->csensitive-1,0)),
17946 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
17947 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
17948 return true;
17949 }
17950 else //2.50.1 and later
17951 {
17952 if(checkdamagecombos(x+4, x+12, y+16, y+24))
17953 return true;
17954 }
17955 }
17956
17957 25248 }
17958
2/2
✓ Branch 0 taken 5402022 times.
✓ Branch 1 taken 4333820 times.
9735842 if (dir < left) bx += (k % 2) ? 7 : 8;
17959 4333820 else by += (k % 2) ? 7 : 8;
17960 9735842 }
17961 3967584 }
17962 2427304 return false;
17963 2436433 }
17964 2438507 void HeroClass::checkpushblock()
17965 {
17966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2438507 times.
2438507 if(toogam) return;
17967
17968
3/4
✓ Branch 0 taken 2438387 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2438387 times.
2438507 if(z!=0||fakez!=0) return;
17969
17970 // Return early in some cases..
17971 2438387 bool earlyReturn=false;
17972
17973
4/4
✓ Branch 0 taken 2429158 times.
✓ Branch 1 taken 9229 times.
✓ Branch 2 taken 2431953 times.
✓ Branch 3 taken 6434 times.
2438387 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
17974
2/2
✓ Branch 0 taken 833460 times.
✓ Branch 1 taken 1598493 times.
2431953 if(x.getInt()&15) earlyReturn=true;
17975
17976 // if(y<16) return;
17977
4/4
✓ Branch 0 taken 6082 times.
✓ Branch 1 taken 2432305 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 1954 times.
2438387 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
17978
17979 2436433 int32_t bx = x.getInt()&0xF0;
17980 2436433 int32_t by = (y.getInt()&0xF0);
17981
17982
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 599210 times.
✓ Branch 2 taken 478637 times.
✓ Branch 3 taken 666577 times.
✓ Branch 4 taken 692009 times.
2436433 switch(dir)
17983 {
17984 case up:
17985
2/2
✓ Branch 0 taken 16449 times.
✓ Branch 1 taken 582761 times.
599210 if(y<16)
17986 {
17987 16449 earlyReturn=true;
17988 16449 break;
17989 }
17990
17991
3/4
✓ Branch 0 taken 81751 times.
✓ Branch 1 taken 501010 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81751 times.
582761 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
17992
17993
2/2
✓ Branch 0 taken 334203 times.
✓ Branch 1 taken 248558 times.
582761 if((int32_t)x&8) bx+=16;
17994
17995 582761 break;
17996
17997 case down:
17998
2/2
✓ Branch 0 taken 18553 times.
✓ Branch 1 taken 460084 times.
478637 if(y>128)
17999 {
18000 18553 earlyReturn=true;
18001 18553 break;
18002 }
18003 else
18004 {
18005 460084 by+=16;
18006
18007
2/2
✓ Branch 0 taken 281950 times.
✓ Branch 1 taken 178134 times.
460084 if((int32_t)x&8) bx+=16;
18008 }
18009
18010 460084 break;
18011
18012 case left:
18013
2/2
✓ Branch 0 taken 22835 times.
✓ Branch 1 taken 643742 times.
666577 if(x<32)
18014 {
18015 22835 earlyReturn=true;
18016 22835 break;
18017 }
18018 else
18019 {
18020 643742 bx-=16;
18021
18022
2/2
✓ Branch 0 taken 388130 times.
✓ Branch 1 taken 255612 times.
643742 if(y.getInt()&8)
18023 {
18024 255612 by+=16;
18025 255612 }
18026 }
18027
18028 643742 break;
18029
18030 case right:
18031
2/2
✓ Branch 0 taken 25468 times.
✓ Branch 1 taken 666541 times.
692009 if(x>208)
18032 {
18033 25468 earlyReturn=true;
18034 25468 break;
18035 }
18036 else
18037 {
18038 666541 bx+=16;
18039
18040
2/2
✓ Branch 0 taken 412202 times.
✓ Branch 1 taken 254339 times.
666541 if(y.getInt()&8)
18041 {
18042 254339 by+=16;
18043 254339 }
18044 }
18045
18046 666541 break;
18047 }
18048
18049
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2436432 times.
2436433 if (checksoliddamage()) return;
18050
18051
2/2
✓ Branch 0 taken 1617514 times.
✓ Branch 1 taken 818918 times.
2436432 if(earlyReturn)
18052 1617514 return;
18053
18054 818918 int32_t itemid=current_item_id(itype_bracelet);
18055 818918 size_t combopos = (by&0xF0)+(bx>>4);
18056
2/2
✓ Branch 0 taken 193400 times.
✓ Branch 1 taken 625518 times.
818918 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
18057
2/2
✓ Branch 0 taken 625518 times.
✓ Branch 1 taken 193400 times.
818918 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
18058
2/2
✓ Branch 0 taken 550997 times.
✓ Branch 1 taken 1921972 times.
2472969 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
18059 {
18060
4/4
✓ Branch 0 taken 326955 times.
✓ Branch 1 taken 1595017 times.
✓ Branch 2 taken 59502 times.
✓ Branch 3 taken 267453 times.
1921972 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
18061
4/4
✓ Branch 0 taken 1102930 times.
✓ Branch 1 taken 551589 times.
✓ Branch 2 taken 1101744 times.
✓ Branch 3 taken 1186 times.
1654519 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
18062 1101744 continue;
18063 552775 mapscr* m = FFCore.tempScreens[lyr];
18064 552775 int32_t f = MAPFLAG2(lyr-1,bx,by);
18065 552775 int32_t f2 = MAPCOMBOFLAG2(lyr-1,bx,by);
18066 552775 int32_t t = combobuf[MAPCOMBOL(lyr,bx,by)].type;
18067
2/2
✓ Branch 0 taken 1310 times.
✓ Branch 1 taken 551465 times.
552775 if (lyr == 0) t = combobuf[MAPCOMBO(bx,by)].type;
18068
18069
8/8
✓ Branch 0 taken 518061 times.
✓ Branch 1 taken 34714 times.
✓ Branch 2 taken 516527 times.
✓ Branch 3 taken 1534 times.
✓ Branch 4 taken 3978 times.
✓ Branch 5 taken 479369 times.
✓ Branch 6 taken 513842 times.
✓ Branch 7 taken 517820 times.
552775 if((t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) && (pushing<16 || hasMainGuy())) continue;
18070
18071
8/8
✓ Branch 0 taken 517706 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 515955 times.
✓ Branch 3 taken 1751 times.
✓ Branch 4 taken 515660 times.
✓ Branch 5 taken 295 times.
✓ Branch 6 taken 695 times.
✓ Branch 7 taken 518375 times.
520491 if((t==cPUSH_HW || t==cPUSH_HEAVY || t==cPUSH_HEAVY2 || t==cPUSH_HW2)
18072
8/8
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 516399 times.
✓ Branch 2 taken 2271 times.
✓ Branch 3 taken 400 times.
✓ Branch 4 taken 295 times.
✓ Branch 5 taken 1976 times.
✓ Branch 6 taken 295 times.
✓ Branch 7 taken 1976 times.
519796 && (itemid<0 || glove->power<((t==cPUSH_HEAVY2 || t==cPUSH_HW2)?2:1) ||
18073
1/4
✓ Branch 0 taken 1976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2671 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
18074
18075 518375 bool doit=false;
18076 518375 bool changeflag=false;
18077 518375 bool changecombo=false;
18078
18079
7/8
✓ Branch 0 taken 517395 times.
✓ Branch 1 taken 980 times.
✓ Branch 2 taken 517395 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 490 times.
✓ Branch 5 taken 517885 times.
✓ Branch 6 taken 113 times.
✓ Branch 7 taken 516877 times.
1035365 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
18080
3/4
✓ Branch 0 taken 517421 times.
✓ Branch 1 taken 464 times.
✓ Branch 2 taken 517421 times.
✗ Branch 3 not taken.
517885 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
18081
4/4
✓ Branch 0 taken 517442 times.
✓ Branch 1 taken 443 times.
✓ Branch 2 taken 517317 times.
✓ Branch 3 taken 125 times.
517885 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
18082
3/4
✓ Branch 0 taken 517440 times.
✓ Branch 1 taken 445 times.
✓ Branch 2 taken 517440 times.
✗ Branch 3 not taken.
517885 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
18083
3/4
✓ Branch 0 taken 517413 times.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 517413 times.
✗ Branch 3 not taken.
517885 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
18084
3/4
✓ Branch 0 taken 517439 times.
✓ Branch 1 taken 446 times.
✓ Branch 2 taken 517439 times.
✗ Branch 3 not taken.
517885 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
18085
2/2
✓ Branch 0 taken 516990 times.
✓ Branch 1 taken 3 times.
516993 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
18086 {
18087 606 changeflag=true;
18088 606 doit=true;
18089 606 }
18090
18091
4/8
✓ Branch 0 taken 517483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517483 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 517483 times.
✓ Branch 6 taken 517483 times.
✗ Branch 7 not taken.
1034966 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
18092
2/4
✓ Branch 0 taken 517483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517483 times.
✗ Branch 3 not taken.
517483 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
18093
2/4
✓ Branch 0 taken 517483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517483 times.
✗ Branch 3 not taken.
517483 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
18094
2/4
✓ Branch 0 taken 517483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517483 times.
✗ Branch 3 not taken.
517483 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
18095
2/4
✓ Branch 0 taken 517483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517483 times.
✗ Branch 3 not taken.
517483 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
18096
2/4
✓ Branch 0 taken 517483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517483 times.
✗ Branch 3 not taken.
517483 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
18097
1/2
✓ Branch 0 taken 517483 times.
✗ Branch 1 not taken.
517483 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
18098 {
18099 changecombo=true;
18100 doit=true;
18101 }
18102
18103
2/2
✓ Branch 0 taken 18011 times.
✓ Branch 1 taken 499472 times.
517483 if(get_bit(quest_rules,qr_SOLIDBLK))
18104 {
18105
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3712 times.
✓ Branch 2 taken 3606 times.
✓ Branch 3 taken 4210 times.
✓ Branch 4 taken 6483 times.
18011 switch(dir)
18106 {
18107 case up:
18108
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3712 times.
✓ Branch 4 taken 2007 times.
✓ Branch 5 taken 1705 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1705 times.
✓ Branch 8 taken 2007 times.
✓ Branch 9 taken 1705 times.
3712 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
18109
18110 3712 break;
18111
18112 case down:
18113
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3606 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 2019 times.
✓ Branch 5 taken 1587 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1587 times.
✓ Branch 8 taken 2019 times.
✓ Branch 9 taken 1587 times.
3606 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
18114
18115 3606 break;
18116
18117 case left:
18118
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4210 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4210 times.
✓ Branch 4 taken 1459 times.
✓ Branch 5 taken 2751 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2751 times.
✓ Branch 8 taken 1459 times.
✓ Branch 9 taken 2751 times.
4210 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
18119
18120 4210 break;
18121
18122 case right:
18123
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6483 times.
✓ Branch 4 taken 2120 times.
✓ Branch 5 taken 4363 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4363 times.
✓ Branch 8 taken 2120 times.
✓ Branch 9 taken 4363 times.
6483 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
18124
18125 6483 break;
18126 }
18127 18011 }
18128
18129
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 212382 times.
✓ Branch 2 taken 181057 times.
✓ Branch 3 taken 61207 times.
✓ Branch 4 taken 62837 times.
517483 switch(dir)
18130 {
18131 case up:
18132
3/4
✓ Branch 0 taken 212050 times.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 212050 times.
212382 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
18133
18134 212382 break;
18135
18136 case down:
18137
3/4
✓ Branch 0 taken 180667 times.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180667 times.
181057 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
18138
18139 181057 break;
18140
18141 case left:
18142
3/4
✓ Branch 0 taken 61125 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61125 times.
61207 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
18143
18144 61207 break;
18145
18146 case right:
18147
3/4
✓ Branch 0 taken 62813 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62813 times.
62837 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
18148
18149 62837 break;
18150 }
18151
18152
2/2
✓ Branch 0 taken 517139 times.
✓ Branch 1 taken 344 times.
517483 if(doit)
18153 {
18154
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 if(limitedpush)
18155 ++usecounts[itemid];
18156
18157 // for(int32_t i=0; i<1; i++)
18158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if(!blockmoving)
18159 {
18160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if(changeflag)
18161 {
18162 344 m->sflag[combopos]=0;
18163 344 }
18164
18165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if(mblock2.clk<=0)
18166 {
18167 344 mblock2.blockLayer = lyr;
18168 344 mblock2.push((zfix)bx,(zfix)by,dir,f);
18169
18170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if(get_bit(quest_rules,qr_MORESOUNDS))
18171 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
18172 344 }
18173 344 }
18174 344 break;
18175 }
18176 517139 }
18177 2438383 }
18178
18179 101 bool usekey()
18180 {
18181 101 int32_t itemid = current_item_id(itype_magickey);
18182
18183
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
101 if(itemid<0 ||
18184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18185 : itemsbuf[itemid].power!=dlevel))
18186 {
18187
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 53 times.
81 if(game->lvlkeys[dlevel]!=0)
18188 {
18189 28 game->lvlkeys[dlevel]--;
18190 //run script for level key item
18191 28 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
18192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2380 times.
2380 for ( int32_t q = 0; q < MAXITEMS; ++q )
18193 {
18194
2/2
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 28 times.
2380 if ( itemsbuf[q].family == itype_lkey )
18195 {
18196 28 key_item = q; break;
18197 }
18198 2352 }
18199
18200
2/8
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18201 {
18202 ri = &(itemScriptData[key_item]);
18203 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18204 ri->Clear();
18205 item_doscript[key_item] = 1;
18206 itemscriptInitialised[key_item] = 0;
18207 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18208 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18209 }
18210 28 return true;
18211 }
18212 else
18213 {
18214
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 50 times.
53 if(game->get_keys()==0)
18215 {
18216 3 return false;
18217 }
18218 else
18219 {
18220 //run script for key item
18221 50 int32_t key_item = 0; //current_item_id(itype_key); //not possible
18222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 500 times.
500 for ( int32_t q = 0; q < MAXITEMS; ++q )
18223 {
18224
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 50 times.
500 if ( itemsbuf[q].family == itype_key )
18225 {
18226 50 key_item = q; break;
18227 }
18228 450 }
18229 //zprint2("key_item is: %d\n",key_item);
18230 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
18231
2/8
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18232 {
18233 ri = &(itemScriptData[key_item]);
18234 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18235 ri->Clear();
18236 item_doscript[key_item] = 1;
18237 itemscriptInitialised[key_item] = 0;
18238 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18239 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18240 }
18241 50 game->change_keys(-1);
18242 }
18243 }
18244 50 }
18245
18246 70 return true;
18247 101 }
18248
18249 bool canUseKey(int32_t num)
18250 {
18251 int32_t itemid = current_item_id(itype_magickey);
18252
18253 if(itemid<0 ||
18254 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18255 : itemsbuf[itemid].power!=dlevel))
18256 {
18257 return game->lvlkeys[dlevel] + game->get_keys() >= num;
18258 }
18259
18260 return true;
18261 }
18262
18263 bool usekey(int32_t num)
18264 {
18265 if(!canUseKey(num)) return false;
18266 for(auto q = 0; q < num; ++q)
18267 {
18268 if(!usekey()) return false; //should never return false here, but, just to be safe....
18269 }
18270 return true;
18271 }
18272
18273
18274 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
18275 {
18276 int32_t mc = (y&0xF0)+(x>>4);
18277 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
18278 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
18279 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
18280 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
18281 return ret;
18282 }
18283
18284 2429158 void HeroClass::oldchecklockblock()
18285 {
18286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2429158 times.
2429158 if(toogam) return;
18287
18288 2429158 int32_t bx = x.getInt()&0xF0;
18289 2429158 int32_t bx2 = int32_t(x+8)&0xF0;
18290 2429158 int32_t by = y.getInt()&0xF0;
18291
18292
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 598011 times.
✓ Branch 2 taken 478032 times.
✓ Branch 3 taken 664503 times.
✓ Branch 4 taken 688612 times.
2429158 switch(dir)
18293 {
18294 case up:
18295
4/4
✓ Branch 0 taken 82790 times.
✓ Branch 1 taken 515221 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 81592 times.
598011 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18296
18297 598011 break;
18298
18299 case down:
18300 478032 by+=16;
18301 478032 break;
18302
18303 case left:
18304
2/2
✓ Branch 0 taken 306735 times.
✓ Branch 1 taken 357768 times.
664503 if((((int32_t)x)&0x0F)<8)
18305 357768 bx-=16;
18306
18307
2/2
✓ Branch 0 taken 402820 times.
✓ Branch 1 taken 261683 times.
664503 if(y.getInt()&8)
18308 {
18309 261683 by+=16;
18310 261683 }
18311
18312 664503 bx2=bx;
18313 664503 break;
18314
18315 case right:
18316 688612 bx+=16;
18317
18318
2/2
✓ Branch 0 taken 429696 times.
✓ Branch 1 taken 258916 times.
688612 if(y.getInt()&8)
18319 {
18320 258916 by+=16;
18321 258916 }
18322
18323 688612 bx2=bx;
18324 688612 break;
18325 }
18326
18327 2429158 bool found1=false;
18328 2429158 bool found2=false;
18329 2429158 int32_t foundlayer = -1;
18330 2429158 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18331 2429158 newcombo const& cmb = combobuf[cid1];
18332 2429158 newcombo const& cmb2 = combobuf[cid2];
18333 // Layer 0 is overridden by Locked Doors
18334
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2429158 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2429158 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
18335 {
18336 found1=true;
18337 foundlayer = 0;
18338 }
18339
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2429158 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2429158 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
18340 {
18341 found2=true;
18342 foundlayer = 0;
18343 }
18344
18345
2/2
✓ Branch 0 taken 4858316 times.
✓ Branch 1 taken 2429158 times.
7287474 for (int32_t i = 0; i <= 1; ++i)
18346 {
18347
2/2
✓ Branch 0 taken 4344867 times.
✓ Branch 1 taken 513449 times.
4858316 if(tmpscr2[i].valid!=0)
18348 {
18349
1/2
✓ Branch 0 taken 513449 times.
✗ Branch 1 not taken.
513449 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18350 {
18351
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 513449 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
513449 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 513449 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
513449 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18353 513449 }
18354 else
18355 {
18356 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18357 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18358 }
18359 513449 }
18360 4858316 }
18361
18362
18363 // Layers
18364
2/4
✓ Branch 0 taken 2429158 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2429158 times.
2429158 if(!(found1 || found2))
18365 {
18366 2429158 foundlayer = -1;
18367
2/2
✓ Branch 0 taken 2429158 times.
✓ Branch 1 taken 4858316 times.
7287474 for(int32_t i=0; i<2; i++)
18368 {
18369 4858316 cid1 = MAPCOMBO2(i, bx, by);
18370 4858316 cid2 = MAPCOMBO2(i, bx2, by);
18371 4858316 newcombo const& cmb = combobuf[cid1];
18372 4858316 newcombo const& cmb2 = combobuf[cid2];
18373
2/2
✓ Branch 0 taken 2429158 times.
✓ Branch 1 taken 2429158 times.
4858316 if (i == 0)
18374 {
18375
1/2
✓ Branch 0 taken 2429158 times.
✗ Branch 1 not taken.
2429158 if(tmpscr2[1].valid!=0)
18376 {
18377 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18378 {
18379 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
18380 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
18381 }
18382 else
18383 {
18384 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18385 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18386 }
18387 }
18388 2429158 }
18389
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4858316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4858316 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18390 {
18391 found1=true;
18392 foundlayer = i+1;
18393 //zprint("Found layer: %d \n", i);
18394 break;
18395 }
18396
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4858316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4858316 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
18397 {
18398 found2=true;
18399 foundlayer = i+1;
18400 //zprint("Found layer: %d \n", i);
18401 break;
18402 }
18403 4858316 }
18404 2429158 }
18405
18406
2/4
✓ Branch 0 taken 2429158 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2429158 times.
✗ Branch 3 not taken.
2429158 if(!(found1 || found2) || pushing<8)
18407 {
18408 2429158 return;
18409 }
18410 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
18411 if(!try_locked_combo(cmb3))
18412 return;
18413
18414 if(cmb.usrflags&cflag16)
18415 {
18416 setxmapflag(1<<cmb.attribytes[5]);
18417 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18418 }
18419 else
18420 {
18421 setmapflag(mLOCKBLOCK);
18422 remove_lockblocks((currscr>=128)?1:0);
18423 }
18424 if ( cmb3.usrflags&cflag3 )
18425 {
18426 if ( (cmb3.attribytes[3]) )
18427 sfx(cmb3.attribytes[3]);
18428 }
18429 else sfx(WAV_DOOR);
18430 2429158 }
18431
18432 2429158 void HeroClass::oldcheckbosslockblock()
18433 {
18434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2429158 times.
2429158 if(toogam) return;
18435
18436 2429158 int32_t bx = x.getInt()&0xF0;
18437 2429158 int32_t bx2 = int32_t(x+8)&0xF0;
18438 2429158 int32_t by = y.getInt()&0xF0;
18439
18440
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 598011 times.
✓ Branch 2 taken 478032 times.
✓ Branch 3 taken 664503 times.
✓ Branch 4 taken 688612 times.
2429158 switch(dir)
18441 {
18442 case up:
18443
4/4
✓ Branch 0 taken 82790 times.
✓ Branch 1 taken 515221 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 81592 times.
598011 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18444
18445 598011 break;
18446
18447 case down:
18448 478032 by+=16;
18449 478032 break;
18450
18451 case left:
18452
2/2
✓ Branch 0 taken 306735 times.
✓ Branch 1 taken 357768 times.
664503 if((((int32_t)x)&0x0F)<8)
18453 357768 bx-=16;
18454
18455
2/2
✓ Branch 0 taken 402820 times.
✓ Branch 1 taken 261683 times.
664503 if(y.getInt()&8)
18456 {
18457 261683 by+=16;
18458 261683 }
18459
18460 664503 bx2=bx;
18461 664503 break;
18462
18463 case right:
18464 688612 bx+=16;
18465
18466
2/2
✓ Branch 0 taken 429696 times.
✓ Branch 1 taken 258916 times.
688612 if(y.getInt()&8)
18467 {
18468 258916 by+=16;
18469 258916 }
18470
18471 688612 bx2=bx;
18472 688612 break;
18473 }
18474
18475
18476 2429158 bool found1 = false;
18477 2429158 bool found2 = false;
18478 2429158 int32_t foundlayer = -1;
18479 2429158 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18480 2429158 newcombo const& cmb = combobuf[cid1];
18481 2429158 newcombo const& cmb2 = combobuf[cid2];
18482 // Layer 0 is overridden by Locked Doors
18483
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2429158 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2429158 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
18484 {
18485 found1 = true;
18486 foundlayer = 0;
18487 }
18488
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2429158 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2429158 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
18489 {
18490 found2 = true;
18491 foundlayer = 0;
18492 }
18493
18494
2/2
✓ Branch 0 taken 4858316 times.
✓ Branch 1 taken 2429158 times.
7287474 for (int32_t i = 0; i <= 1; ++i)
18495 {
18496
2/2
✓ Branch 0 taken 4344867 times.
✓ Branch 1 taken 513449 times.
4858316 if (tmpscr2[i].valid != 0)
18497 {
18498
1/2
✓ Branch 0 taken 513449 times.
✗ Branch 1 not taken.
513449 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18499 {
18500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 513449 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
513449 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18501
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 513449 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
513449 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18502 513449 }
18503 else
18504 {
18505 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18506 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18507 }
18508 513449 }
18509 4858316 }
18510
18511
18512 // Layers
18513
2/4
✓ Branch 0 taken 2429158 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2429158 times.
2429158 if (!(found1 || found2))
18514 {
18515 2429158 foundlayer = -1;
18516
2/2
✓ Branch 0 taken 2429158 times.
✓ Branch 1 taken 4858316 times.
7287474 for (int32_t i = 0; i < 2; i++)
18517 {
18518 4858316 cid1 = MAPCOMBO2(i, bx, by);
18519 4858316 cid2 = MAPCOMBO2(i, bx2, by);
18520 4858316 newcombo const& cmb = combobuf[cid1];
18521 4858316 newcombo const& cmb2 = combobuf[cid2];
18522
2/2
✓ Branch 0 taken 2429158 times.
✓ Branch 1 taken 2429158 times.
4858316 if (i == 0)
18523 {
18524
1/2
✓ Branch 0 taken 2429158 times.
✗ Branch 1 not taken.
2429158 if (tmpscr2[1].valid != 0)
18525 {
18526 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18527 {
18528 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18529 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18530 }
18531 else
18532 {
18533 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18534 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18535 }
18536 }
18537 2429158 }
18538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4858316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4858316 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
18539 {
18540 found1 = true;
18541 foundlayer = i;
18542 break;
18543 }
18544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4858316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4858316 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
18545 {
18546 found2 = true;
18547 foundlayer = i;
18548 break;
18549 }
18550 4858316 }
18551 2429158 }
18552
18553
2/4
✓ Branch 0 taken 2429158 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2429158 times.
✗ Branch 3 not taken.
2429158 if (!(found1 || found2) || pushing < 8)
18554 {
18555 2429158 return;
18556 }
18557 int32_t cid = found1 ? cid1 : cid2;
18558
18559 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18560
18561
18562 // Run Boss Key Script
18563 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18564 for ( int32_t q = 0; q < MAXITEMS; ++q )
18565 {
18566 if ( itemsbuf[q].family == itype_bosskey )
18567 {
18568 key_item = q; break;
18569 }
18570 }
18571 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18572 {
18573 ri = &(itemScriptData[key_item]);
18574 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18575 ri->Clear();
18576 item_doscript[key_item] = 1;
18577 itemscriptInitialised[key_item] = 0;
18578 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18579 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18580 }
18581
18582 if(cmb.usrflags&cflag16)
18583 {
18584 setxmapflag(1<<cmb.attribytes[5]);
18585 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18586 }
18587 else
18588 {
18589 setmapflag(mBOSSLOCKBLOCK);
18590 remove_bosslockblocks((currscr>=128)?1:0);
18591 }
18592 if ( (combobuf[cid].attribytes[3]) )
18593 sfx(combobuf[cid].attribytes[3]);
18594 2429158 }
18595
18596 7287474 void HeroClass::oldcheckchest(int32_t type)
18597 {
18598 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
18599
3/6
✓ Branch 0 taken 7287474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7287474 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7287474 times.
7287474 if(toogam || z>0 || fakez > 0) return;
18600
2/2
✓ Branch 0 taken 7163595 times.
✓ Branch 1 taken 123879 times.
7287474 if(pushing<8) return;
18601 123879 int32_t bx = x.getInt()&0xF0;
18602 123879 int32_t bx2 = int32_t(x+8)&0xF0;
18603 123879 int32_t by = y.getInt()&0xF0;
18604
18605
3/4
✓ Branch 0 taken 53655 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34968 times.
✓ Branch 3 taken 35256 times.
123879 switch(dir)
18606 {
18607 case up:
18608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35256 times.
35256 if(isSideViewHero()) return;
18609
18610
3/4
✓ Branch 0 taken 9711 times.
✓ Branch 1 taken 25545 times.
✓ Branch 2 taken 9711 times.
✗ Branch 3 not taken.
35256 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18611
18612 35256 break;
18613
18614 case left:
18615 case right:
18616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53655 times.
53655 if(isSideViewHero()) break;
18617 [[fallthrough]];
18618 case down:
18619 88623 return;
18620 }
18621
18622 35256 bool found=false;
18623 35256 bool itemflag=false;
18624
18625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35256 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35256 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
18626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35256 times.
35256 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
18627 {
18628 found=true;
18629 }
18630
2/2
✓ Branch 0 taken 70512 times.
✓ Branch 1 taken 35256 times.
105768 for (int32_t i = 0; i <= 1; ++i)
18631 {
18632
2/2
✓ Branch 0 taken 58320 times.
✓ Branch 1 taken 12192 times.
70512 if(tmpscr2[i].valid!=0)
18633 {
18634
1/2
✓ Branch 0 taken 12192 times.
✗ Branch 1 not taken.
12192 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18635 {
18636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12192 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12192 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18638 12192 }
18639 else
18640 {
18641 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18642 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18643 }
18644 12192 }
18645 70512 }
18646
18647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35256 times.
35256 if(!found)
18648 {
18649
2/2
✓ Branch 0 taken 35256 times.
✓ Branch 1 taken 70512 times.
105768 for(int32_t i=0; i<2; i++)
18650 {
18651
2/2
✓ Branch 0 taken 35256 times.
✓ Branch 1 taken 35256 times.
70512 if (i == 0)
18652 {
18653
1/2
✓ Branch 0 taken 35256 times.
✗ Branch 1 not taken.
35256 if(tmpscr2[1].valid!=0)
18654 {
18655 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18656 {
18657 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18658 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18659 }
18660 else
18661 {
18662 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18663 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18664 }
18665 }
18666 35256 }
18667
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
70512 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
18668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70512 times.
70512 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
18669 {
18670 found=true;
18671 break;
18672 }
18673 70512 }
18674 35256 }
18675
18676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35256 times.
35256 if(!found)
18677 {
18678 35256 return;
18679 }
18680
18681 switch(type)
18682 {
18683 case cLOCKEDCHEST:
18684 if(!usekey()) return;
18685
18686 setmapflag(mLOCKEDCHEST);
18687 break;
18688
18689 case cCHEST:
18690 setmapflag(mCHEST);
18691 break;
18692
18693 case cBOSSCHEST:
18694 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18695 // Run Boss Key Script
18696 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18697 for ( int32_t q = 0; q < MAXITEMS; ++q )
18698 {
18699 if ( itemsbuf[q].family == itype_bosskey )
18700 {
18701 key_item = q; break;
18702 }
18703 }
18704 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18705 {
18706 ri = &(itemScriptData[key_item]);
18707 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18708 ri->Clear();
18709 item_doscript[key_item] = 1;
18710 itemscriptInitialised[key_item] = 0;
18711 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18712 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18713 }
18714 setmapflag(mBOSSCHEST);
18715 break;
18716 }
18717
18718 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18719 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18720 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
18721 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
18722 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18723 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18724
18725 if(!itemflag)
18726 {
18727 for(int32_t i=0; i<2; i++)
18728 {
18729 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
18730 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
18731 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
18732 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
18733 }
18734 }
18735
18736 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
18737 {
18738 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
18739 }
18740 7287474 }
18741
18742 46730 void HeroClass::checkchest(int32_t type)
18743 {
18744
4/4
✓ Branch 0 taken 37384 times.
✓ Branch 1 taken 9346 times.
✓ Branch 2 taken 9346 times.
✓ Branch 3 taken 28038 times.
46730 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
18745
2/2
✓ Branch 0 taken 9346 times.
✓ Branch 1 taken 37384 times.
46730 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
18746
2/2
✓ Branch 0 taken 9346 times.
✓ Branch 1 taken 37384 times.
46730 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
18747
2/2
✓ Branch 0 taken 9346 times.
✓ Branch 1 taken 37384 times.
46730 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
18748
2/2
✓ Branch 0 taken 18692 times.
✓ Branch 1 taken 28038 times.
46730 if(ischest)
18749 {
18750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28038 times.
28038 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
18751 {
18752 oldcheckchest(type);
18753 return;
18754 }
18755 28038 }
18756
3/4
✓ Branch 0 taken 18692 times.
✓ Branch 1 taken 28038 times.
✓ Branch 2 taken 18692 times.
✗ Branch 3 not taken.
46730 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
18757 {
18758 if(type == cLOCKBLOCK)
18759 oldchecklockblock();
18760 else if(type == cBOSSLOCKBLOCK)
18761 oldcheckbosslockblock();
18762 return;
18763 }
18764
4/6
✓ Branch 0 taken 46730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46130 times.
✓ Branch 3 taken 600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46130 times.
46730 if(toogam || z>0 || fakez > 0) return;
18765 46130 zfix bx, by;
18766 46130 zfix bx2, by2;
18767 46130 zfix fx(-1), fy(-1);
18768
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7475 times.
✓ Branch 2 taken 3600 times.
✓ Branch 3 taken 13775 times.
✓ Branch 4 taken 21280 times.
46130 switch(dir)
18769 {
18770 case up:
18771 7475 by = y + (bigHitbox ? -2 : 6);
18772 7475 by2 = by;
18773 7475 bx = x + 4;
18774 7475 bx2 = bx + 8;
18775 7475 break;
18776 case down:
18777 3600 by = y + 17;
18778 3600 by2 = by;
18779 3600 bx = x + 4;
18780 3600 bx2 = bx + 8;
18781 3600 break;
18782 case left:
18783 13775 by = y + (bigHitbox ? 0 : 8);
18784 13775 by2 = y + 8;
18785 13775 bx = x - 2;
18786 13775 bx2 = x - 2;
18787 13775 break;
18788 case right:
18789 21280 by = y + (bigHitbox ? 0 : 8);
18790 21280 by2 = y + 8;
18791 21280 bx = x + 17;
18792 21280 bx2 = x + 17;
18793 21280 break;
18794 }
18795
18796 46130 int32_t found = -1;
18797 46130 int32_t foundlayer = 0;
18798
18799 46130 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
18800
18801
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
46130 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
18802 {
18803 found = MAPCOMBO(bx,by);
18804 fx = bx; fy = by;
18805 for (int32_t i = 0; i <= 1; ++i)
18806 {
18807 if(tmpscr2[i].valid!=0)
18808 {
18809 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18810 {
18811 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18812 }
18813 else
18814 {
18815 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18816 }
18817 }
18818 }
18819 }
18820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
46130 if(found<0)
18821 {
18822 46130 cmb = &combobuf[MAPCOMBO(bx2,by2)];
18823
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
46130 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
18824 {
18825 found = MAPCOMBO(bx2,by2);
18826 for (int32_t i = 0; i <= 6; ++i)
18827 {
18828 if(tmpscr2[i].valid!=0)
18829 {
18830 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18831 {
18832 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
18833 {
18834 found = -1;
18835 break;
18836 }
18837 }
18838 else
18839 {
18840 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
18841 {
18842 found = -1;
18843 break;
18844 }
18845 }
18846 }
18847 }
18848 if(found != -1)
18849 {
18850 fx = bx2; fy = by2;
18851 }
18852 }
18853 46130 }
18854
18855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
46130 if(found<0)
18856 {
18857
2/2
✓ Branch 0 taken 46130 times.
✓ Branch 1 taken 276780 times.
322910 for(int32_t i=0; i<6; i++)
18858 {
18859 276780 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
18860
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
276780 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18861 {
18862 found = MAPCOMBO2(i,bx,by);
18863 for(int32_t j = i+1; j < 6; ++j)
18864 {
18865 if (tmpscr2[j].valid!=0)
18866 {
18867 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18868 {
18869 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
18870 {
18871 found = -1;
18872 break;
18873 }
18874 }
18875 else
18876 {
18877 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
18878 {
18879 found = -1;
18880 break;
18881 }
18882 }
18883 }
18884 }
18885 if(found>-1)
18886 {
18887 foundlayer = i+1;
18888 fx = bx; fy = by;
18889 break;
18890 }
18891 }
18892 276780 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
18893
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
276780 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
18894 {
18895 found = MAPCOMBO2(i,bx2,by2);
18896 for(int32_t j = i+1; j < 6; ++j)
18897 {
18898 if (tmpscr2[j].valid!=0)
18899 {
18900 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18901 {
18902 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
18903 {
18904 found = -1;
18905 break;
18906 }
18907 }
18908 else
18909 {
18910 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
18911 {
18912 found = -1;
18913 break;
18914 }
18915 }
18916 }
18917 }
18918 if(found>-1)
18919 {
18920 foundlayer = i+1;
18921 fx = bx2; fy = by2;
18922 break;
18923 }
18924 }
18925 276780 }
18926 46130 }
18927
18928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46130 times.
46130 if(found<0) return;
18929 cmb = &combobuf[found];
18930 switch(dir)
18931 {
18932 case up:
18933 if(cmb->usrflags&cflag10)
18934 return;
18935 break;
18936 case down:
18937 if(cmb->usrflags&cflag9)
18938 return;
18939 break;
18940 case left:
18941 if(cmb->usrflags&cflag12)
18942 return;
18943 break;
18944 case right:
18945 if(cmb->usrflags&cflag11)
18946 return;
18947 break;
18948 }
18949 int32_t intbtn = cmb->attribytes[2];
18950
18951 if(intbtn) //
18952 {
18953 if(cmb->usrflags & cflag13) //display prompt
18954 {
18955 int altcmb = cmb->attributes[2]/10000;
18956 prompt_combo = cmb->attributes[1]/10000;
18957 if(altcmb && ((islocked && !can_locked_combo(*cmb))
18958 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
18959 prompt_combo = altcmb;
18960 prompt_cset = cmb->attribytes[4];
18961 prompt_x = cmb->attrishorts[0];
18962 prompt_y = cmb->attrishorts[1];
18963 }
18964 if(!getIntBtnInput(intbtn, true, true, false, false))
18965 {
18966 return; //Button not pressed
18967 }
18968 }
18969 else if(pushing < 8) return; //Not pushing against chest enough
18970
18971 if(ischest)
18972 {
18973 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
18974 }
18975 else if(islockblock)
18976 {
18977 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
18978 }
18979 if(intbtn && (cmb->usrflags & cflag13))
18980 prompt_combo = 0;
18981 46730 }
18982
18983 2441884 void HeroClass::checkgenpush()
18984 {
18985
4/4
✓ Branch 0 taken 42002 times.
✓ Branch 1 taken 2399882 times.
✓ Branch 2 taken 34711 times.
✓ Branch 3 taken 7291 times.
2441884 if(pushing < 8 || pushing % 8) return;
18986 7291 zfix bx, by;
18987 7291 zfix bx2, by2;
18988
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2142 times.
✓ Branch 2 taken 2062 times.
✓ Branch 3 taken 1320 times.
✓ Branch 4 taken 1767 times.
7291 switch(dir)
18989 {
18990 case up:
18991 2142 by = y + (bigHitbox ? -2 : 6);
18992 2142 by2 = by;
18993 2142 bx = x + 4;
18994 2142 bx2 = bx + 8;
18995 2142 break;
18996 case down:
18997 2062 by = y + 17;
18998 2062 by2 = by;
18999 2062 bx = x + 4;
19000 2062 bx2 = bx + 8;
19001 2062 break;
19002 case left:
19003 1320 by = y + (bigHitbox ? 0 : 8);
19004 1320 by2 = y + 8;
19005 1320 bx = x - 2;
19006 1320 bx2 = x - 2;
19007 1320 break;
19008 case right:
19009 1767 by = y + (bigHitbox ? 0 : 8);
19010 1767 by2 = y + 8;
19011 1767 bx = x + 17;
19012 1767 bx2 = x + 17;
19013 1767 break;
19014 }
19015 7291 auto pos1 = COMBOPOS(bx,by);
19016 7291 auto pos2 = COMBOPOS(bx2,by2);
19017
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 51037 times.
58328 for(auto layer = 0; layer < 7; ++layer)
19018 {
19019 51037 mapscr* tmp = FFCore.tempScreens[layer];
19020
19021 51037 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
19022
1/2
✓ Branch 0 taken 51037 times.
✗ Branch 1 not taken.
51037 if(cmb1.triggerflags[1] & combotriggerPUSH)
19023 do_trigger_combo(layer,pos1);
19024
19025
2/2
✓ Branch 0 taken 36960 times.
✓ Branch 1 taken 14077 times.
51037 if(pos1==pos2) continue;
19026
19027 14077 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
19028
1/2
✓ Branch 0 taken 14077 times.
✗ Branch 1 not taken.
14077 if(cmb2.triggerflags[1] & combotriggerPUSH)
19029 do_trigger_combo(layer,pos2);
19030 14077 }
19031
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 7186 times.
7291 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19032 {
19033 105 word c = tmpscr->numFFC();
19034
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1283 times.
1388 for(word i=0; i<c; i++)
19035 {
19036
4/4
✓ Branch 0 taken 1229 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1226 times.
1283 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19037 {
19038 57 ffcdata& ffc = tmpscr->ffcs[i];
19039 57 newcombo const& cmb3 = combobuf[ffc.getData()];
19040
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(cmb3.triggerflags[1] & combotriggerPUSH)
19041 {
19042 do_trigger_combo_ffc(i);
19043 break;
19044 }
19045 57 }
19046 1283 }
19047 105 }
19048 2441884 }
19049
19050 2441884 void HeroClass::checksigns() //Also checks for generic trigger buttons
19051 {
19052
4/6
✓ Branch 0 taken 2441884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441764 times.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2441764 times.
2441884 if(toogam || z>0 || fakez>0) return;
19053
5/6
✓ Branch 0 taken 2418034 times.
✓ Branch 1 taken 23730 times.
✓ Branch 2 taken 33496 times.
✓ Branch 3 taken 2384538 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33496 times.
2441764 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
19054 23730 return; //Don't overwrite a message waiting to be dismissed
19055 2418034 zfix bx, by;
19056 2418034 zfix bx2, by2;
19057 2418034 zfix fx(-1), fy(-1);
19058
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 580736 times.
✓ Branch 2 taken 478741 times.
✓ Branch 3 taken 664161 times.
✓ Branch 4 taken 694396 times.
2418034 switch(dir)
19059 {
19060 case up:
19061 580736 by = y + (bigHitbox ? -2 : 6);
19062 580736 by2 = by;
19063 580736 bx = x + 4;
19064 580736 bx2 = bx + 8;
19065 580736 break;
19066 case down:
19067 478741 by = y + 17;
19068 478741 by2 = by;
19069 478741 bx = x + 4;
19070 478741 bx2 = bx + 8;
19071 478741 break;
19072 case left:
19073 664161 by = y + (bigHitbox ? 0 : 8);
19074 664161 by2 = y + 8;
19075 664161 bx = x - 2;
19076 664161 bx2 = x - 2;
19077 664161 break;
19078 case right:
19079 694396 by = y + (bigHitbox ? 0 : 8);
19080 694396 by2 = y + 8;
19081 694396 bx = x + 17;
19082 694396 bx2 = x + 17;
19083 694396 break;
19084 }
19085
19086 2418034 int32_t found = -1;
19087 2418034 int32_t foundffc = -1;
19088 2418034 int32_t found_lyr = 0;
19089 2418034 bool found_sign = false;
19090 2418034 int32_t tmp_cid = MAPCOMBO(bx,by);
19091 2418034 newcombo const* tmp_cmb = &combobuf[tmp_cid];
19092
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2418034 times.
✓ Branch 2 taken 2418034 times.
✗ Branch 3 not taken.
4836068 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19093 2418034 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
19094 {
19095 found = tmp_cid;
19096 fx = bx; fy = by;
19097 for (int32_t i = 0; i <= 1; ++i)
19098 {
19099 if(tmpscr2[i].valid!=0)
19100 {
19101 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19102 {
19103 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19104 }
19105 else
19106 {
19107 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19108 }
19109 }
19110 }
19111 }
19112 2418034 tmp_cid = MAPCOMBO(bx2,by2);
19113 2418034 tmp_cmb = &combobuf[tmp_cid];
19114
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2418034 times.
✓ Branch 2 taken 2418034 times.
✗ Branch 3 not taken.
4836068 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19115 2418034 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
19116 {
19117 found = tmp_cid;
19118 fx = bx2; fy = by2;
19119 for (int32_t i = 0; i <= 1; ++i)
19120 {
19121 if(tmpscr2[i].valid!=0)
19122 {
19123 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19124 {
19125 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19126 }
19127 else
19128 {
19129 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19130 }
19131 }
19132 }
19133 }
19134
19135
2/2
✓ Branch 0 taken 2409235 times.
✓ Branch 1 taken 8799 times.
2418034 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19136 {
19137 8799 word c = tmpscr->numFFC();
19138
2/2
✓ Branch 0 taken 8799 times.
✓ Branch 1 taken 129337 times.
138136 for(word i=0; i<c; i++)
19139 {
19140
4/4
✓ Branch 0 taken 128274 times.
✓ Branch 1 taken 1063 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 128230 times.
129337 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19141 {
19142 1107 ffcdata& ffc = tmpscr->ffcs[i];
19143 1107 tmp_cmb = &combobuf[ffc.getData()];
19144
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1107 times.
1107 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19145 1107 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
19146 {
19147 foundffc = i;
19148 break;
19149 }
19150 1107 }
19151 129337 }
19152 8799 }
19153
19154
2/4
✓ Branch 0 taken 2418034 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2418034 times.
2418034 if(found<0 && foundffc < 0)
19155 {
19156
2/2
✓ Branch 0 taken 2418034 times.
✓ Branch 1 taken 14508204 times.
16926238 for(int32_t i=0; i<6; i++)
19157 {
19158 14508204 tmp_cid = MAPCOMBO2(i,bx,by);
19159 14508204 tmp_cmb = &combobuf[tmp_cid];
19160
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14508204 times.
✓ Branch 2 taken 14508204 times.
✗ Branch 3 not taken.
29016408 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19161 14508204 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
19162 {
19163 found = tmp_cid;
19164 found_lyr = i+1;
19165 fx = bx; fy = by;
19166 if (i == 0 && tmpscr2[1].valid!=0)
19167 {
19168 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19169 {
19170 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19171 }
19172 else
19173 {
19174 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19175 }
19176 }
19177 }
19178 14508204 tmp_cid = MAPCOMBO2(i,bx2,by2);
19179 14508204 tmp_cmb = &combobuf[tmp_cid];
19180
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14508204 times.
✓ Branch 2 taken 14508204 times.
✗ Branch 3 not taken.
29016408 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19181 14508204 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
19182 {
19183 found = tmp_cid;
19184 found_lyr = i+1;
19185 fx = bx2; fy = by2;
19186 if (i == 0 && tmpscr2[1].valid!=0)
19187 {
19188 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19189 {
19190 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19191 }
19192 else
19193 {
19194 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19195 }
19196 }
19197 }
19198
1/2
✓ Branch 0 taken 14508204 times.
✗ Branch 1 not taken.
14508204 if(found>-1) break;
19199 14508204 }
19200 2418034 }
19201
19202
2/4
✓ Branch 0 taken 2418034 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2418034 times.
2418034 if(found<0&&foundffc<0) return;
19203 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
19204
19205 byte signInput = 0;
19206 bool didsign = false;
19207 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
19208 {
19209 switch(dir)
19210 {
19211 case up:
19212 if(cmb.usrflags&cflag10)
19213 goto endsigns;
19214 break;
19215 case down:
19216 if(cmb.usrflags&cflag9)
19217 goto endsigns;
19218 break;
19219 case left:
19220 if(cmb.usrflags&cflag12)
19221 goto endsigns;
19222 break;
19223 case right:
19224 if(cmb.usrflags&cflag11)
19225 goto endsigns;
19226 break;
19227 }
19228 int32_t intbtn = cmb.attribytes[2];
19229
19230 if(intbtn) //
19231 {
19232 signInput = getIntBtnInput(intbtn, true, true, false, false);
19233 if(!signInput)
19234 {
19235 if(cmb.usrflags & cflag13) //display prompt
19236 {
19237 prompt_combo = cmb.attributes[1]/10000;
19238 prompt_cset = cmb.attribytes[4];
19239 prompt_x = cmb.attrishorts[0];
19240 prompt_y = cmb.attrishorts[1];
19241 }
19242 goto endsigns; //Button not pressed
19243 }
19244 }
19245 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
19246
19247 trigger_sign(cmb);
19248 didsign = true;
19249 }
19250 endsigns:
19251 if(!cmb.triggerbtn) return;
19252 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
19253 switch(dir)
19254 {
19255 case down:
19256 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
19257 return;
19258 break;
19259 case up:
19260 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
19261 return;
19262 break;
19263 case right:
19264 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
19265 return;
19266 break;
19267 case left:
19268 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
19269 return;
19270 break;
19271 }
19272 if(getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput))
19273 {
19274 if (foundffc >= 0)
19275 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
19276 else
19277 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
19278 }
19279 else if(cmb.type == cBUTTONPROMPT)
19280 {
19281 prompt_combo = cmb.attributes[0]/10000;
19282 prompt_cset = cmb.attribytes[0];
19283 prompt_x = cmb.attrishorts[0];
19284 prompt_y = cmb.attrishorts[1];
19285 }
19286 else if(cmb.prompt_cid)
19287 {
19288 prompt_combo = cmb.prompt_cid;
19289 prompt_cset = cmb.prompt_cs;
19290 prompt_x = cmb.prompt_x;
19291 prompt_y = cmb.prompt_y;
19292 }
19293 2441884 }
19294
19295 2438507 void HeroClass::checklocked()
19296 {
19297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2438507 times.
2438507 if(toogam) return; //Walk through walls.
19298
19299
2/2
✓ Branch 0 taken 1817280 times.
✓ Branch 1 taken 621227 times.
2438507 if(!isdungeon()) return;
19300
19301
3/4
✓ Branch 0 taken 1817280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3130 times.
✓ Branch 3 taken 1814150 times.
1817280 if( !diagonalMovement && pushing!=8) return;
19302 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
19303 */
19304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3130 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
19305
19306
19307 3130 bool found = false;
19308
2/2
✓ Branch 0 taken 12520 times.
✓ Branch 1 taken 3130 times.
15650 for ( int32_t q = 0; q < 4; q++ ) {
19309
4/4
✓ Branch 0 taken 12147 times.
✓ Branch 1 taken 373 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 12007 times.
12520 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
19310 12520 }
19311
19312
2/2
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 2648 times.
3130 if ( !found ) return;
19313
19314 482 int32_t si = (currmap<<7) + currscr;
19315 482 int32_t di = 0;
19316
19317
19318
19319
2/4
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 482 times.
482 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
19320 {
19321 //Up door
19322 if ( y <= 32 && x >= 112 && x <= 128 )
19323 {
19324 if (
19325 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
19326
19327 )
19328 {
19329 di = nextscr(up);
19330 if(tmpscr->door[0]==dLOCKED)
19331 {
19332 if(usekey())
19333 {
19334 putdoor(scrollbuf,0,up,dUNLOCKED);
19335 tmpscr->door[0]=dUNLOCKED;
19336 setmapflag(si, mDOOR_UP);
19337
19338 if(di != 0xFFFF)
19339 setmapflag(di, mDOOR_DOWN);
19340 sfx(WAV_DOOR);
19341 markBmap(-1);
19342 }
19343 else return;
19344 }
19345 else if(tmpscr->door[0]==dBOSS)
19346 {
19347 if(game->lvlitems[dlevel]&liBOSSKEY)
19348 {
19349 putdoor(scrollbuf,0,up,dOPENBOSS);
19350 tmpscr->door[0]=dOPENBOSS;
19351 setmapflag(si, mDOOR_UP);
19352
19353 if(di != 0xFFFF)
19354 setmapflag(di, mDOOR_DOWN);
19355 sfx(WAV_DOOR);
19356 markBmap(-1);
19357 // Run Boss Key Script
19358 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19359 for ( int32_t q = 0; q < MAXITEMS; ++q )
19360 {
19361 if ( itemsbuf[q].family == itype_bosskey )
19362 {
19363 key_item = q; break;
19364 }
19365 }
19366 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19367 {
19368 ri = &(itemScriptData[key_item]);
19369 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19370 ri->Clear();
19371 item_doscript[key_item] = 1;
19372 itemscriptInitialised[key_item] = 0;
19373 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19374 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19375 }
19376 }
19377 else return;
19378
19379 }
19380
19381 }
19382 }
19383 //Down
19384 if ( y >= 128 && x >= 112 && x <= 128 )
19385 {
19386 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
19387 {
19388 di = nextscr(down);
19389 if(tmpscr->door[1]==dLOCKED)
19390 {
19391 if(usekey())
19392 {
19393 putdoor(scrollbuf,0,down,dUNLOCKED);
19394 tmpscr->door[1]=dUNLOCKED;
19395 setmapflag(si, mDOOR_DOWN);
19396
19397 if(di != 0xFFFF)
19398 setmapflag(di, mDOOR_UP);
19399 sfx(WAV_DOOR);
19400 markBmap(-1);
19401 }
19402 else return;
19403 }
19404 else if(tmpscr->door[1]==dBOSS)
19405 {
19406 if(game->lvlitems[dlevel]&liBOSSKEY)
19407 {
19408 putdoor(scrollbuf,0,down,dOPENBOSS);
19409 tmpscr->door[1]=dOPENBOSS;
19410 setmapflag(si, mDOOR_DOWN);
19411
19412 if(di != 0xFFFF)
19413 setmapflag(di, mDOOR_UP);
19414 sfx(WAV_DOOR);
19415 markBmap(-1);
19416 // Run Boss Key Script
19417 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19418 for ( int32_t q = 0; q < MAXITEMS; ++q )
19419 {
19420 if ( itemsbuf[q].family == itype_bosskey )
19421 {
19422 key_item = q; break;
19423 }
19424 }
19425 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19426 {
19427 ri = &(itemScriptData[key_item]);
19428 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19429 ri->Clear();
19430 item_doscript[key_item] = 1;
19431 itemscriptInitialised[key_item] = 0;
19432 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19433 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19434 }
19435 }
19436 else return;
19437 }
19438 }
19439 }
19440 //left
19441 if ( y > 72 && y < 88 && x <= 32 )
19442 {
19443 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
19444 {
19445 di = nextscr(left);
19446 if(tmpscr->door[2]==dLOCKED)
19447 {
19448 if(usekey())
19449 {
19450 putdoor(scrollbuf,0,left,dUNLOCKED);
19451 tmpscr->door[2]=dUNLOCKED;
19452 setmapflag(si, mDOOR_LEFT);
19453
19454 if(di != 0xFFFF)
19455 setmapflag(di, mDOOR_RIGHT);
19456 sfx(WAV_DOOR);
19457 markBmap(-1);
19458 }
19459 else return;
19460 }
19461 else if(tmpscr->door[2]==dBOSS)
19462 {
19463 if(game->lvlitems[dlevel]&liBOSSKEY)
19464 {
19465 putdoor(scrollbuf,0,left,dOPENBOSS);
19466 tmpscr->door[2]=dOPENBOSS;
19467 setmapflag(si, mDOOR_LEFT);
19468
19469 if(di != 0xFFFF)
19470 setmapflag(di, mDOOR_RIGHT);
19471 sfx(WAV_DOOR);
19472 markBmap(-1);
19473 // Run Boss Key Script
19474 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19475 for ( int32_t q = 0; q < MAXITEMS; ++q )
19476 {
19477 if ( itemsbuf[q].family == itype_bosskey )
19478 {
19479 key_item = q; break;
19480 }
19481 }
19482 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19483 {
19484 ri = &(itemScriptData[key_item]);
19485 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19486 ri->Clear();
19487 item_doscript[key_item] = 1;
19488 itemscriptInitialised[key_item] = 0;
19489 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19490 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19491 }
19492 }
19493 else return;
19494 }
19495 }
19496 }
19497
19498
19499 //right
19500 if ( ( y > 72 && y < 88 ) && x >= 208 )
19501 //!( (y<=72||y>=88) && x<206 ) )
19502 //y<=72||y>=88):y!=80) || x<208)
19503 {
19504 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
19505 {
19506 di = nextscr(right);
19507 if(tmpscr->door[right]==dLOCKED)
19508 {
19509 if(usekey())
19510 {
19511 putdoor(scrollbuf,0,right,dUNLOCKED);
19512 tmpscr->door[3]=dUNLOCKED;
19513 setmapflag(si, mDOOR_RIGHT);
19514
19515 if(di != 0xFFFF)
19516 setmapflag(di, mDOOR_LEFT);
19517 sfx(WAV_DOOR);
19518 markBmap(-1);
19519 }
19520 else return;
19521 }
19522 else if(tmpscr->door[right]==dBOSS)
19523 {
19524 if(game->lvlitems[dlevel]&liBOSSKEY)
19525 {
19526 putdoor(scrollbuf,0,right,dOPENBOSS);
19527 tmpscr->door[3]=dOPENBOSS;
19528 setmapflag(si, mDOOR_RIGHT);
19529
19530 if(di != 0xFFFF)
19531 setmapflag(di, mDOOR_LEFT);
19532 sfx(WAV_DOOR);
19533 markBmap(-1);
19534 // Run Boss Key Script
19535 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19536 for ( int32_t q = 0; q < MAXITEMS; ++q )
19537 {
19538 if ( itemsbuf[q].family == itype_bosskey )
19539 {
19540 key_item = q; break;
19541 }
19542 }
19543 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19544 {
19545 ri = &(itemScriptData[key_item]);
19546 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19547 ri->Clear();
19548 item_doscript[key_item] = 1;
19549 itemscriptInitialised[key_item] = 0;
19550 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19551 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19552 }
19553 }
19554 else return;
19555 }
19556
19557 }
19558 }
19559 }
19560 else
19561 {
19562 //orthogonal movement
19563 //Up door
19564
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 375 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 69 times.
482 if ( y<=32 && x == 120 )
19565 //!( y>32 && (x!=120) ))
19566 {
19567
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 1 times.
69 switch ( dir )
19568 {
19569 case up:
19570 case r_up:
19571 case l_up:
19572 {
19573 68 di = nextscr(up);
19574
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 16 times.
68 if(tmpscr->door[0]==dLOCKED)
19575 {
19576
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1 times.
52 if(usekey())
19577 {
19578 51 putdoor(scrollbuf,0,up,dUNLOCKED);
19579 51 tmpscr->door[0]=dUNLOCKED;
19580 51 setmapflag(si, mDOOR_UP);
19581
19582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(di != 0xFFFF)
19583 51 setmapflag(di, mDOOR_DOWN);
19584 51 sfx(WAV_DOOR);
19585 51 markBmap(-1);
19586 51 }
19587 1 else return;
19588 51 }
19589
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 else if(tmpscr->door[0]==dBOSS)
19590 {
19591
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(game->lvlitems[dlevel]&liBOSSKEY)
19592 {
19593 11 putdoor(scrollbuf,0,up,dOPENBOSS);
19594 11 tmpscr->door[0]=dOPENBOSS;
19595 11 setmapflag(si, mDOOR_UP);
19596
19597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(di != 0xFFFF)
19598 11 setmapflag(di, mDOOR_DOWN);
19599 11 sfx(WAV_DOOR);
19600 11 markBmap(-1);
19601 // Run Boss Key Script
19602 11 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
748 for ( int32_t q = 0; q < MAXITEMS; ++q )
19604 {
19605
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 11 times.
748 if ( itemsbuf[q].family == itype_bosskey )
19606 {
19607 11 key_item = q; break;
19608 }
19609 737 }
19610
2/8
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19611 {
19612 ri = &(itemScriptData[key_item]);
19613 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19614 ri->Clear();
19615 item_doscript[key_item] = 1;
19616 itemscriptInitialised[key_item] = 0;
19617 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19618 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19619 }
19620 11 }
19621 1 else return;
19622 11 }
19623 66 break;
19624 }
19625 1 default: break;
19626
19627 }
19628 67 }
19629 //Down
19630
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 423 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 13 times.
480 if ( y >= 128 && x == 120 )
19631 //!(y<128 && (x!=120) ) )
19632 {
19633
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
13 switch(dir)
19634 {
19635 case down:
19636 case l_down:
19637 case r_down:
19638 {
19639 12 di = nextscr(down);
19640
19641
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(tmpscr->door[1]==dLOCKED)
19642 {
19643
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(usekey())
19644 {
19645 7 putdoor(scrollbuf,0,down,dUNLOCKED);
19646 7 tmpscr->door[1]=dUNLOCKED;
19647 7 setmapflag(si, mDOOR_DOWN);
19648
19649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
19650 7 setmapflag(di, mDOOR_UP);
19651 7 sfx(WAV_DOOR);
19652 7 markBmap(-1);
19653 7 }
19654 1 else return;
19655 7 }
19656
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(tmpscr->door[1]==dBOSS)
19657 {
19658
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->lvlitems[dlevel]&liBOSSKEY)
19659 {
19660 2 putdoor(scrollbuf,0,down,dOPENBOSS);
19661 2 tmpscr->door[1]=dOPENBOSS;
19662 2 setmapflag(si, mDOOR_DOWN);
19663
19664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(di != 0xFFFF)
19665 2 setmapflag(di, mDOOR_UP);
19666 2 sfx(WAV_DOOR);
19667 2 markBmap(-1);
19668 // Run Boss Key Script
19669 2 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 for ( int32_t q = 0; q < MAXITEMS; ++q )
19671 {
19672
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2 times.
136 if ( itemsbuf[q].family == itype_bosskey )
19673 {
19674 2 key_item = q; break;
19675 }
19676 134 }
19677
2/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19678 {
19679 ri = &(itemScriptData[key_item]);
19680 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19681 ri->Clear();
19682 item_doscript[key_item] = 1;
19683 itemscriptInitialised[key_item] = 0;
19684 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19685 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19686 }
19687 2 }
19688 else return;
19689 2 }
19690 11 break;
19691 }
19692 1 default: break;
19693 }
19694 12 }
19695 //left
19696
4/4
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 28 times.
479 if ( y == 80 && x <= 32 )
19697 //!( (y!=80) && x>32 ) )
19698 {
19699
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1 times.
28 switch(dir)
19700 {
19701 case left:
19702 case l_up:
19703 case l_down:
19704 {
19705 27 di = nextscr(left);
19706
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 if(tmpscr->door[2]==dLOCKED)
19707 {
19708
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(usekey())
19709 {
19710 17 putdoor(scrollbuf,0,left,dUNLOCKED);
19711 17 tmpscr->door[2]=dUNLOCKED;
19712 17 setmapflag(si, mDOOR_LEFT);
19713
19714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(di != 0xFFFF)
19715 17 setmapflag(di, mDOOR_RIGHT);
19716 17 sfx(WAV_DOOR);
19717 17 markBmap(-1);
19718 17 }
19719 1 else return;
19720 17 }
19721
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 else if(tmpscr->door[2]==dBOSS)
19722 {
19723
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 if(game->lvlitems[dlevel]&liBOSSKEY)
19724 {
19725 3 putdoor(scrollbuf,0,left,dOPENBOSS);
19726 3 tmpscr->door[2]=dOPENBOSS;
19727 3 setmapflag(si, mDOOR_LEFT);
19728
19729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(di != 0xFFFF)
19730 3 setmapflag(di, mDOOR_RIGHT);
19731 3 sfx(WAV_DOOR);
19732 3 markBmap(-1);
19733 // Run Boss Key Script
19734 3 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 for ( int32_t q = 0; q < MAXITEMS; ++q )
19736 {
19737
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 3 times.
204 if ( itemsbuf[q].family == itype_bosskey )
19738 {
19739 3 key_item = q; break;
19740 }
19741 201 }
19742
2/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19743 {
19744 ri = &(itemScriptData[key_item]);
19745 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19746 ri->Clear();
19747 item_doscript[key_item] = 1;
19748 itemscriptInitialised[key_item] = 0;
19749 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19750 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19751 }
19752 3 }
19753 1 else return;
19754 3 }
19755
19756 25 break;
19757
19758 }
19759 1 default: break;
19760 }
19761 26 }
19762 //right
19763
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 36 times.
477 if ( y == 80 && x >= 208 )
19764 //!((y!=80) && x<208 ) )
19765 {
19766
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 switch(dir)
19767 {
19768 case right:
19769 case r_down:
19770 case r_up:
19771 {
19772 35 di = nextscr(right);
19773
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 12 times.
35 if(tmpscr->door[3]==dLOCKED)
19774 {
19775
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(usekey())
19776 {
19777 23 putdoor(scrollbuf,0,right,dUNLOCKED);
19778 23 tmpscr->door[3]=dUNLOCKED;
19779 23 setmapflag(si, mDOOR_RIGHT);
19780
19781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(di != 0xFFFF)
19782 23 setmapflag(di, mDOOR_LEFT);
19783 23 sfx(WAV_DOOR);
19784 23 markBmap(-1);
19785 23 }
19786 else return;
19787 23 }
19788
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5 times.
12 else if(tmpscr->door[3]==dBOSS)
19789 {
19790
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19791 {
19792 5 putdoor(scrollbuf,0,right,dOPENBOSS);
19793 5 tmpscr->door[3]=dOPENBOSS;
19794 5 setmapflag(si, mDOOR_RIGHT);
19795
19796
19797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(di != 0xFFFF)
19798 5 setmapflag(di, mDOOR_LEFT);
19799 5 sfx(WAV_DOOR);
19800 5 markBmap(-1);
19801 // Run Boss Key Script
19802 5 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 for ( int32_t q = 0; q < MAXITEMS; ++q )
19804 {
19805
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 5 times.
340 if ( itemsbuf[q].family == itype_bosskey )
19806 {
19807 5 key_item = q; break;
19808 }
19809 335 }
19810
2/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
19811 {
19812 ri = &(itemScriptData[key_item]);
19813 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19814 ri->Clear();
19815 item_doscript[key_item] = 1;
19816 itemscriptInitialised[key_item] = 0;
19817 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19818 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19819 }
19820
19821 5 }
19822 else return;
19823 5 }
19824
19825
19826 35 break;
19827 }
19828 1 default: break;
19829
19830 }
19831 36 }
19832 }
19833 2438507 }
19834
19835 2438507 void HeroClass::checkswordtap()
19836 {
19837
3/6
✓ Branch 0 taken 1491089 times.
✓ Branch 1 taken 947418 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1491089 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2438507 if(attack!=wSword || charging<=0 || pushing<8) return;
19838
19839 int32_t bx=x;
19840 int32_t by=y+8;
19841
19842 switch(dir)
19843 {
19844 case up:
19845 if(!Up()) return;
19846
19847 by-=16;
19848 break;
19849
19850 case down:
19851 if(!Down()) return;
19852
19853 by+=16;
19854 bx+=8;
19855 break;
19856
19857 case left:
19858 if(!Left()) return;
19859
19860 bx-=16;
19861 by+=8;
19862 break;
19863
19864 case right:
19865 if(!Right()) return;
19866
19867 bx+=16;
19868 by+=8;
19869 break;
19870 }
19871
19872 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
19873
19874 attackclk=SWORDTAPFRAME;
19875 pushing=-8; //16 frames between taps
19876 tapping=true;
19877
19878 int32_t type = COMBOTYPE(bx,by);
19879
19880 if(!isCuttableType(type))
19881 {
19882 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
19883 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
19884
19885 // Layers
19886 for(int32_t i=0; i < 6; i++)
19887 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
19888 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
19889
19890 for(int32_t i=0; i<4; i++)
19891 if(tmpscr->door[i]==dBOMB && i==dir)
19892 switch(i)
19893 {
19894 case up:
19895 case down:
19896 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
19897
19898 break;
19899
19900 case left:
19901 case right:
19902 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
19903
19904 break;
19905 }
19906
19907 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
19908 }
19909
19910 2438507 }
19911
19912 11326 void HeroClass::fairycircle(int32_t type)
19913 {
19914
2/2
✓ Branch 0 taken 9703 times.
✓ Branch 1 taken 1623 times.
11326 if(fairyclk==0)
19915 {
19916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1623 switch(type)
19917 {
19918 case REFILL_LIFE:
19919
2/2
✓ Branch 0 taken 1570 times.
✓ Branch 1 taken 53 times.
1623 if(didstuff&did_fairy) return;
19920
19921 53 didstuff|=did_fairy;
19922 53 break;
19923
19924 case REFILL_MAGIC:
19925 if(didstuff&did_magic) return;
19926
19927 didstuff|=did_magic;
19928 break;
19929
19930 case REFILL_ALL:
19931 if(didstuff&did_all) return;
19932
19933 didstuff|=did_all;
19934 }
19935
19936 53 refill_what=type;
19937 53 refill_why=REFILL_FAIRY;
19938 53 StartRefill(type);
19939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
19940 53 else {action=freeze; FFCore.setHeroAction(freeze);}
19941 53 holdclk=0;
19942 53 hopclk=0;
19943 53 }
19944
19945 9756 ++fairyclk;
19946
19947
2/2
✓ Branch 0 taken 5463 times.
✓ Branch 1 taken 4293 times.
9756 if(refilling!=REFILL_FAIRYDONE)
19948 {
19949
2/2
✓ Branch 0 taken 5410 times.
✓ Branch 1 taken 53 times.
5463 if(!refill())
19950 53 refilling=REFILL_FAIRYDONE;
19951 5463 }
19952
19953
2/2
✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 53 times.
4293 else if(++holdclk>80)
19954 {
19955 53 reset_swordcharge();
19956 53 attackclk=0;
19957 53 action=none; FFCore.setHeroAction(none);
19958 53 fairyclk=0;
19959 53 holdclk=0;
19960 53 refill_why = 0;
19961 53 refilling=REFILL_NONE;
19962 53 map_bkgsfx(true);
19963 53 }
19964 11326 }
19965
19966 138527 int32_t touchcombo(int32_t x,int32_t y)
19967 {
19968
2/2
✓ Branch 0 taken 277054 times.
✓ Branch 1 taken 138527 times.
415581 for (int32_t i = 0; i <= 1; ++i)
19969 {
19970
2/2
✓ Branch 0 taken 233500 times.
✓ Branch 1 taken 43554 times.
277054 if(tmpscr2[i].valid!=0)
19971 {
19972
2/2
✓ Branch 0 taken 43430 times.
✓ Branch 1 taken 124 times.
43554 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19973 {
19974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43430 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19975 43430 }
19976 else
19977 {
19978
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19979 }
19980 43554 }
19981 277054 }
19982
2/2
✓ Branch 0 taken 138505 times.
✓ Branch 1 taken 22 times.
138527 if (!_effectflag(x,y,1, -1)) return 0;
19983 138505 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
19984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138505 times.
138505 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19985 return 0;
19986
3/3
✓ Branch 0 taken 1537 times.
✓ Branch 1 taken 135890 times.
✓ Branch 2 taken 1078 times.
138505 switch(cmb.type)
19987 {
19988 case cBSGRAVE:
19989 case cGRAVE:
19990
3/4
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 784 times.
✓ Branch 2 taken 753 times.
✗ Branch 3 not taken.
1537 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
19991 {
19992 784 break;
19993 }
19994
19995 [[fallthrough]];
19996 case cARMOS:
19997 {
19998 1831 return cmb.type;
19999 }
20000 }
20001
20002 136674 return 0;
20003 138527 }
20004
20005 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
20006 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
20007
20008 static int32_t GridX(int32_t x)
20009 {
20010 return (x >> 4) << 4;
20011 }
20012
20013 //Snaps 'y' to the combo grid
20014 //Equivalent to calling ComboY(ComboAt(foo,y));
20015 static int32_t GridY(int32_t y)
20016 {
20017 return (y >> 4) << 4;
20018 }
20019
20020 int32_t grabComboFromPos(int32_t pos, int32_t type)
20021 {
20022 for(int32_t lyr = 6; lyr > -1; --lyr)
20023 {
20024 int32_t id = FFCore.tempScreens[lyr]->data[pos];
20025 if(combobuf[id].type == type)
20026 return id;
20027 }
20028 return -1;
20029 }
20030
20031 static int32_t typeMap[176];
20032 static int32_t istrig[176];
20033 static const int32_t SPTYPE_SOLID = -1;
20034 #define SP_VISITED 0x1
20035 #define SPFLAG(dir) (0x2<<dir)
20036 #define BEAM_AGE_LIMIT 32
20037 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
20038 {
20039 int32_t trigflag = set ? (1 << (set-1)) : ~0;
20040 if(spotdir > 3) return; //invalid dir
20041 bool doAge = true;
20042 byte f = 0;
20043 while(unsigned(curpos) < 176)
20044 {
20045 bool block_light = false;
20046 f = SPFLAG(spotdir);
20047 if((grid[curpos] & f) != f)
20048 {
20049 grid[curpos] |= f;
20050 istrig[curpos] |= trigflag;
20051 doAge = false;
20052 age = 0;
20053 }
20054 switch(spotdir)
20055 {
20056 case up:
20057 curpos -= 0x10;
20058 break;
20059 case down:
20060 curpos += 0x10;
20061 break;
20062 case left:
20063 if(!(curpos%0x10))
20064 curpos = -1;
20065 else --curpos;
20066 break;
20067 case right:
20068 ++curpos;
20069 if(!(curpos%0x10))
20070 curpos = -1;
20071 break;
20072 }
20073 if(unsigned(curpos) >= 176) break;
20074 switch(typeMap[curpos])
20075 {
20076 case SPTYPE_SOLID: case cBLOCKALL:
20077 curpos = -1;
20078 break;
20079 }
20080 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
20081 curpos = -1;
20082 if(unsigned(curpos) >= 176) break;
20083
20084 f = SPFLAG(oppositeDir[spotdir]);
20085 if((grid[curpos] & f) != f)
20086 {
20087 grid[curpos] |= f;
20088 istrig[curpos] |= trigflag;
20089 doAge = false;
20090 age = 0;
20091 }
20092 if(doAge)
20093 {
20094 if(++age > BEAM_AGE_LIMIT)
20095 break;
20096 }
20097 else doAge = true;
20098
20099 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
20100 spotdir = dir;
20101 else switch(typeMap[curpos])
20102 {
20103 case cLIGHTTARGET:
20104 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
20105 return;
20106 case cMIRROR:
20107 spotdir = oppositeDir[spotdir];
20108 break;
20109 case cMIRRORSLASH:
20110 switch(spotdir)
20111 {
20112 case up:
20113 spotdir = right; break;
20114 case right:
20115 spotdir = up; break;
20116 case down:
20117 spotdir = left; break;
20118 case left:
20119 spotdir = down; break;
20120 }
20121 break;
20122 case cMIRRORBACKSLASH:
20123 switch(spotdir)
20124 {
20125 case up:
20126 spotdir = left; break;
20127 case left:
20128 spotdir = up; break;
20129 case down:
20130 spotdir = right; break;
20131 case right:
20132 spotdir = down; break;
20133 }
20134 break;
20135 case cMAGICPRISM:
20136 for(byte d = 0; d < 4; ++d)
20137 {
20138 if(d == oppositeDir[spotdir]) continue;
20139 handleBeam(grid, age, d, curpos, set, block, refl);
20140 }
20141 return;
20142 case cMAGICPRISM4:
20143 for(byte d = 0; d < 4; ++d)
20144 {
20145 handleBeam(grid, age, d, curpos, set, block, refl);
20146 }
20147 return;
20148 }
20149 }
20150 }
20151
20152 2441644 void HeroClass::handleSpotlights()
20153 {
20154 typedef byte spot_t;
20155 //Store each different tile/color as grids
20156 2441644 std::map<int32_t, spot_t*> maps;
20157
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 int32_t shieldid = getCurrentShield(false);
20158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441644 times.
2441644 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
20159
2/4
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2441644 times.
2441644 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
20160
3/6
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441644 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2441644 times.
✗ Branch 5 not taken.
2441644 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
20161 2441644 memset(istrig, 0, sizeof(istrig));
20162
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 clear_bitmap(lightbeam_bmp);
20163
20164
2/2
✓ Branch 0 taken 429729344 times.
✓ Branch 1 taken 2441644 times.
432170988 for(size_t pos = 0; pos < 176; ++pos)
20165 {
20166 429729344 typeMap[pos] = 0;
20167
2/2
✓ Branch 0 taken 429686038 times.
✓ Branch 1 taken 3008105408 times.
3437791446 for(int32_t lyr = 6; lyr > -1; --lyr)
20168 {
20169 3008105408 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
20170
2/3
✓ Branch 0 taken 43306 times.
✓ Branch 1 taken 3008062102 times.
✗ Branch 2 not taken.
3008105408 switch(cmb->type)
20171 {
20172 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
20173 case cMAGICPRISM: case cMAGICPRISM4:
20174 case cBLOCKALL: case cLIGHTTARGET:
20175 43306 typeMap[pos] = cmb->type;
20176 43306 break;
20177 case cGLASS:
20178 typeMap[pos] = 0;
20179 break;
20180 default:
20181 {
20182
4/4
✓ Branch 0 taken 1289144726 times.
✓ Branch 1 taken 1718917376 times.
✓ Branch 2 taken 1027098769 times.
✓ Branch 3 taken 262045957 times.
3008062102 if(lyr < 3 && (cmb->walk & 0xF))
20183 {
20184 262045957 typeMap[pos] = SPTYPE_SOLID;
20185 262045957 }
20186 3008062102 continue; //next layer
20187 }
20188 }
20189 43306 break; //hit a combo type
20190 }
20191 429729344 }
20192
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 2441529 times.
2441644 if(unsigned(heropos) < 176)
20193 {
20194
2/2
✓ Branch 0 taken 191784 times.
✓ Branch 1 taken 2249745 times.
2441529 switch(typeMap[heropos])
20195 {
20196 case SPTYPE_SOLID: case cBLOCKALL:
20197 191784 heropos = -1; //Blocked from hitting player
20198 191784 }
20199 2441529 }
20200
20201
2/2
✓ Branch 0 taken 17091508 times.
✓ Branch 1 taken 2441644 times.
19533152 for(size_t layer = 0; layer < 7; ++layer)
20202 {
20203 17091508 mapscr* curlayer = FFCore.tempScreens[layer];
20204
2/2
✓ Branch 0 taken 3008105408 times.
✓ Branch 1 taken 17091508 times.
3025196916 for(size_t pos = 0; pos < 176; ++pos)
20205 {
20206 //For each spotlight combo on each layer...
20207 3008105408 newcombo const& cmb = combobuf[curlayer->data[pos]];
20208
1/2
✓ Branch 0 taken 3008105408 times.
✗ Branch 1 not taken.
3008105408 if(cmb.type == cSPOTLIGHT)
20209 {
20210 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
20211 int32_t id = (cmb.usrflags&cflag1)
20212 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
20213 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
20214 if(!id) continue;
20215 // zprint2("ID = %ld\n", id);
20216 //Get the grid array for this tile/color
20217 spot_t* grid;
20218 if(maps[id])
20219 grid = maps[id];
20220 else
20221 {
20222 grid = new spot_t[176];
20223 memset(grid, 0, sizeof(spot_t)*176);
20224 maps[id] = grid;
20225 }
20226 byte spotdir = cmb.attribytes[0];
20227 int32_t curpos = pos;
20228 if(spotdir > 3)
20229 {
20230 grid[curpos] |= SP_VISITED;
20231 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
20232 }
20233 if(refl && curpos == heropos)
20234 {
20235 spotdir = dir;
20236 }
20237 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
20238 }
20239 3008105408 }
20240 17091508 }
20241
20242 //Draw visuals
20243
2/4
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2441644 times.
2441644 for(auto it = maps.begin(); it != maps.end();)
20244 {
20245 int32_t id = it->first;
20246 spot_t* grid = it->second;
20247 //
20248 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
20249 int32_t tile = (id&0xFFFFFF);
20250 int32_t cs = (id>>24);
20251 byte c_inner = ((-id)&0x0000FF);
20252 byte c_middle = ((-id)&0x00FF00)>>8;
20253 byte c_outter = ((-id)&0xFF0000)>>16;
20254 //{ Setup color bitmap
20255 BITMAP* cbmp = NULL;
20256 if(id < 0)
20257 {
20258 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
20259 cbmp = create_bitmap_ex(8, 16*t_max, 16);
20260 clear_bitmap(cbmp);
20261 for(size_t q = 1; q < t_max; ++q)
20262 {
20263 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
20264 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
20265 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
20266 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
20267 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
20268 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
20269 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
20270 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
20271 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
20272 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
20273 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
20274 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
20275 }
20276 //t_gr
20277 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
20278 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
20279 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
20280 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
20281 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
20282 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
20283 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
20284 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
20285 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
20286 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
20287 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
20288 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
20289 //t_up
20290 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
20291 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
20292 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
20293 //t_down
20294 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
20295 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
20296 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
20297 //t_left
20298 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
20299 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
20300 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
20301 //t_right
20302 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
20303 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
20304 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
20305 //t_uleft
20306 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
20307 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
20308 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
20309 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
20310 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
20311 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
20312 //t_uright
20313 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
20314 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
20315 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
20316 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
20317 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
20318 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
20319 //t_dleft
20320 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
20321 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
20322 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
20323 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
20324 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
20325 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
20326 //t_dright
20327 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
20328 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
20329 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
20330 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
20331 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
20332 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
20333 //t_vert
20334 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
20335 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
20336 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
20337 //t_horz
20338 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
20339 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
20340 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
20341 //t_notup
20342 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
20343 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
20344 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
20345 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
20346 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
20347 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
20348 //t_notdown
20349 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
20350 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
20351 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
20352 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
20353 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
20354 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
20355 //t_notleft
20356 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
20357 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
20358 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
20359 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
20360 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
20361 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
20362 //t_notright
20363 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
20364 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
20365 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
20366 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
20367 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
20368 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
20369 //t_all
20370 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
20371 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
20372 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
20373 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
20374 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
20375 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
20376 }
20377 //}
20378 //
20379 for(size_t pos = 0; pos < 176; ++pos)
20380 {
20381 int32_t offs = -1;
20382 switch(grid[pos]>>1)
20383 {
20384 case 0: default:
20385 if(grid[pos])
20386 {
20387 offs = t_gr;
20388 break;
20389 }
20390 continue; //no draw this pos
20391 case 0b0001:
20392 offs = t_up;
20393 break;
20394 case 0b0010:
20395 offs = t_down;
20396 break;
20397 case 0b0100:
20398 offs = t_left;
20399 break;
20400 case 0b1000:
20401 offs = t_right;
20402 break;
20403 case 0b0011:
20404 offs = t_vert;
20405 break;
20406 case 0b1100:
20407 offs = t_horz;
20408 break;
20409 case 0b0101:
20410 offs = t_uleft;
20411 break;
20412 case 0b1001:
20413 offs = t_uright;
20414 break;
20415 case 0b0110:
20416 offs = t_dleft;
20417 break;
20418 case 0b1010:
20419 offs = t_dright;
20420 break;
20421 case 0b1110:
20422 offs = t_notup;
20423 break;
20424 case 0b1101:
20425 offs = t_notdown;
20426 break;
20427 case 0b1011:
20428 offs = t_notleft;
20429 break;
20430 case 0b0111:
20431 offs = t_notright;
20432 break;
20433 case 0b1111:
20434 offs = t_all;
20435 break;
20436 }
20437 if(id > 0) //tile
20438 {
20439 //Draw 'tile' at 'pos'
20440 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
20441 }
20442 else //colors
20443 {
20444 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
20445 }
20446 }
20447 //
20448 if(cbmp) destroy_bitmap(cbmp);
20449 delete[] it->second;
20450 it = maps.erase(it);
20451 }
20452 //Check triggers
20453 2441644 bool hastrigs = false, istrigged = true;
20454
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 bool alltrig = getmapflag(mLIGHTBEAM);
20455
2/2
✓ Branch 0 taken 2441644 times.
✓ Branch 1 taken 17091508 times.
19533152 for(size_t layer = 0; layer < 7; ++layer)
20456 {
20457 17091508 mapscr* curlayer = FFCore.tempScreens[layer];
20458
2/2
✓ Branch 0 taken 3008105408 times.
✓ Branch 1 taken 17091508 times.
3025196916 for(size_t pos = 0; pos < 176; ++pos)
20459 {
20460 3008105408 newcombo const* cmb = &combobuf[curlayer->data[pos]];
20461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3008105408 times.
3008105408 if(cmb->type == cLIGHTTARGET)
20462 {
20463 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20464 hastrigs = true;
20465 bool trigged = (istrig[pos]&trigflag);
20466 if(cmb->usrflags&cflag2) //Invert
20467 trigged = !trigged;
20468 if(cmb->usrflags&cflag1) //Solved Version
20469 {
20470 if(!(alltrig || trigged)) //Revert
20471 {
20472 curlayer->data[pos] -= 1;
20473 istrigged = false;
20474 }
20475 }
20476 else //Unsolved version
20477 {
20478 if(alltrig || trigged) //Light
20479 curlayer->data[pos] += 1;
20480 else istrigged = false;
20481 }
20482 }
20483
1/2
✓ Branch 0 taken 3008105408 times.
✗ Branch 1 not taken.
3008105408 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20484 {
20485 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20486 bool trigged = (istrig[pos]&trigflag);
20487 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20488 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20489 {
20490 do_trigger_combo(layer, pos);
20491 }
20492 }
20493 3008105408 }
20494 17091508 }
20495
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 word c = tmpscr->numFFC();
20496
2/2
✓ Branch 0 taken 2441644 times.
✓ Branch 1 taken 77977748 times.
80419392 for(word i=0; i<c; i++)
20497 {
20498 77977748 ffcdata& ffc = tmpscr->ffcs[i];
20499
1/2
✓ Branch 0 taken 77977748 times.
✗ Branch 1 not taken.
77977748 newcombo const* cmb = &combobuf[ffc.getData()];
20500
7/14
✓ Branch 0 taken 77977748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77977748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77977748 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 77977748 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 77977748 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 77977748 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 77977748 times.
✗ Branch 13 not taken.
77977748 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
20501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77977748 times.
77977748 if(cmb->type == cLIGHTTARGET)
20502 {
20503 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20504 hastrigs = true;
20505 bool trigged = (istrig[pos]&trigflag);
20506 if(cmb->usrflags&cflag2) //Invert
20507 trigged = !trigged;
20508 if(cmb->usrflags&cflag1) //Solved Version
20509 {
20510 if(!(alltrig || trigged)) //Revert
20511 {
20512 ffc.incData(-1);
20513 istrigged = false;
20514 }
20515 }
20516 else //Unsolved version
20517 {
20518 if(alltrig || trigged) //Light
20519 ffc.incData(1);
20520 else istrigged = false;
20521 }
20522 }
20523
1/2
✓ Branch 0 taken 77977748 times.
✗ Branch 1 not taken.
77977748 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20524 {
20525 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20526 bool trigged = (istrig[pos]&trigflag);
20527 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20528 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20529 {
20530 do_trigger_combo_ffc(i);
20531 }
20532 }
20533 77977748 }
20534
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2441644 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2441644 if(hastrigs && istrigged && !alltrig)
20535 {
20536 hidden_entrance(0,true,false,-7);
20537 sfx(tmpscr->secretsfx);
20538 if(!(tmpscr->flags5&fTEMPSECRETS))
20539 {
20540 setmapflag(mSECRET);
20541 setmapflag(mLIGHTBEAM);
20542 }
20543 }
20544 2441644 }
20545
20546 2438507 void HeroClass::checktouchblk()
20547 {
20548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2438507 times.
2438507 if(toogam) return;
20549
20550
2/2
✓ Branch 0 taken 88344 times.
✓ Branch 1 taken 2350163 times.
2438507 if(!pushing)
20551 2350163 return;
20552
20553 88344 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
20554
20555
2/4
✓ Branch 0 taken 88344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88344 times.
88344 if(charging > 0 || spins > 0) //if not I probably will at some point...
20556 {
20557 if(Up()&&Left())tdir = (charging%2)*2;
20558 else if(Up()&&Right())tdir = (charging%2)*3;
20559 else if(Down()&&Left())tdir = 1+(charging%2)*1;
20560 else if(Down()&&Right())tdir = 1+(charging%2)*2;
20561 else
20562 {
20563 if(Up())tdir=0;
20564 else if(Down())tdir=1;
20565 else if(Left())tdir=2;
20566 else if(Right())tdir=3;
20567 }
20568 }
20569
20570 88344 int32_t tx=0,ty=-1;
20571
20572
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 27022 times.
✓ Branch 2 taken 24286 times.
✓ Branch 3 taken 16545 times.
✓ Branch 4 taken 20491 times.
88344 switch(tdir)
20573 {
20574 case up:
20575
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 26999 times.
27022 if(touchcombo(x,y+(bigHitbox?0:7)))
20576 {
20577 23 tx=x;
20578 23 ty=y+(bigHitbox?0:7);
20579 23 }
20580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26999 times.
26999 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
20581 {
20582 tx=x+8;
20583 ty=y+(bigHitbox?0:7);
20584 }
20585
20586 27022 break;
20587
20588 case down:
20589
2/2
✓ Branch 0 taken 1102 times.
✓ Branch 1 taken 23184 times.
24286 if(touchcombo(x,y+16))
20590 {
20591 1102 tx=x;
20592 1102 ty=y+16;
20593 1102 }
20594
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 23019 times.
23184 else if(touchcombo(x+8,y+16))
20595 {
20596 165 tx=x+8;
20597 165 ty=y+16;
20598 165 }
20599
20600 24286 break;
20601
20602 case left:
20603
2/2
✓ Branch 0 taken 16352 times.
✓ Branch 1 taken 193 times.
16545 if(touchcombo(x-1,y+15))
20604 {
20605 193 tx=x-1;
20606 193 ty=y+15;
20607 193 }
20608
20609 16545 break;
20610
20611 case right:
20612
2/2
✓ Branch 0 taken 20143 times.
✓ Branch 1 taken 348 times.
20491 if(touchcombo(x+16,y+15))
20613 {
20614 348 tx=x+16;
20615 348 ty=y+15;
20616 348 }
20617
20618 20491 break;
20619 }
20620
20621
2/2
✓ Branch 0 taken 86513 times.
✓ Branch 1 taken 1831 times.
88344 if(ty>=0)
20622 {
20623 1831 ty&=0xF0;
20624 1831 tx&=0xF0;
20625 1831 int32_t di = ty+(tx>>4);
20626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1831 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1831 if((getAction() != hopping || isSideViewHero()))
20627 {
20628 1831 trigger_armos_grave(0, di, dir);
20629 1831 }
20630 1831 }
20631 2438507 }
20632
20633 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
20634 {
20635 switch(cdir)
20636 {
20637 case up:
20638 cy-=16;
20639 break;
20640
20641 case down:
20642 cy+=16;
20643 break;
20644
20645 case left:
20646 cx-=16;
20647 break;
20648
20649 case right:
20650 cx+=16;
20651 break;
20652 }
20653
20654 // off the screen
20655 if(cx<0 || cy<0 || cx>255 || cy>175)
20656 {
20657 int32_t ns = nextscr(cdir);
20658
20659 if(ns==0xFFFF) return 0;
20660
20661 // want actual screen index, not game->maps[] index
20662 ns = (ns&127) + (ns>>7)*MAPSCRS;
20663
20664 switch(cdir)
20665 {
20666 case up:
20667 cy=160;
20668 break;
20669
20670 case down:
20671 cy=0;
20672 break;
20673
20674 case left:
20675 cx=240;
20676 break;
20677
20678 case right:
20679 cx=0;
20680 break;
20681 }
20682
20683 // from MAPCOMBO()
20684 int32_t cmb = (cy&0xF0)+(cx>>4);
20685
20686 if(cmb>175)
20687 return 0;
20688
20689 return TheMaps[ns].data[cmb]; // entire combo code
20690 }
20691
20692 return MAPCOMBO(cx,cy);
20693 }
20694
20695 1875 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
20696 {
20697
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 387 times.
✓ Branch 3 taken 478 times.
✓ Branch 4 taken 538 times.
1875 switch(cdir)
20698 {
20699 case up:
20700 472 cy-=16;
20701 472 break;
20702
20703 case down:
20704 387 cy+=16;
20705 387 break;
20706
20707 case left:
20708 478 cx-=16;
20709 478 break;
20710
20711 case right:
20712 538 cx+=16;
20713 538 break;
20714 }
20715
20716 // off the screen
20717
8/8
✓ Branch 0 taken 1861 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 1832 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 1812 times.
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 15 times.
✓ Branch 7 taken 1797 times.
1875 if(cx<0 || cy<0 || cx>255 || cy>175)
20718 {
20719 78 int32_t ns = nextscr(cdir);
20720
20721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if(ns==0xFFFF) return 0;
20722
20723 // want actual screen index, not game->maps[] index
20724 78 ns = (ns&127) + (ns>>7)*MAPSCRS;
20725
20726
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 20 times.
78 switch(cdir)
20727 {
20728 case up:
20729 29 cy=160;
20730 29 break;
20731
20732 case down:
20733 15 cy=0;
20734 15 break;
20735
20736 case left:
20737 14 cx=240;
20738 14 break;
20739
20740 case right:
20741 20 cx=0;
20742 20 break;
20743 }
20744
20745 // from MAPCOMBO()
20746 78 int32_t cmb = (cy&0xF0)+(cx>>4);
20747
20748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if(cmb>175)
20749 return 0;
20750
20751
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 71 times.
78 if(!comboflag)
20752 {
20753 71 return TheMaps[ns].sflag[cmb]; // flag
20754 }
20755 else
20756 {
20757 7 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
20758 }
20759 }
20760
20761
2/2
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 1338 times.
1797 if(comboflag)
20762 {
20763 459 return MAPCOMBOFLAG(cx,cy);
20764 }
20765
20766 1338 return MAPFLAG(cx,cy);
20767 1875 }
20768
20769 bool did_secret;
20770
20771 2438507 void HeroClass::checkspecial()
20772 {
20773 2438507 checktouchblk();
20774
20775 2438507 bool hasmainguy = hasMainGuy(); // calculate it once
20776
20777
4/4
✓ Branch 0 taken 2405733 times.
✓ Branch 1 taken 32774 times.
✓ Branch 2 taken 1847582 times.
✓ Branch 3 taken 558151 times.
2438507 if(!(loaded_enemies && !hasmainguy))
20778 1880356 did_secret=false;
20779 else
20780 {
20781 // after beating enemies
20782
20783 // item
20784
2/2
✓ Branch 0 taken 557933 times.
✓ Branch 1 taken 218 times.
558151 if(hasitem&(4|2|1))
20785 {
20786 218 int32_t Item=tmpscr->item;
20787
20788 //if(getmapflag())
20789 // Item=0;
20790
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218 times.
218 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20791 {
20792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(hasitem==1)
20793 218 sfx(WAV_CLEARED);
20794
20795
2/4
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218 times.
✗ Branch 3 not taken.
436 items.add(new item((zfix)tmpscr->itemx,
20796
6/12
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 218 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 218 times.
✗ Branch 11 not taken.
218 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20797
6/10
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 204 times.
✗ Branch 9 not taken.
218 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20799 218 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20800 218 }
20801
20802 218 hasitem &= ~ (4|2|1);
20803 218 }
20804
20805 // generic 'Enemies->' trigger
20806
2/2
✓ Branch 0 taken 3907057 times.
✓ Branch 1 taken 558151 times.
4465208 for(auto lyr = 0; lyr < 7; ++lyr)
20807 {
20808
2/2
✓ Branch 0 taken 687642032 times.
✓ Branch 1 taken 3907057 times.
691549089 for(auto pos = 0; pos < 176; ++pos)
20809 {
20810 687642032 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
20811
1/2
✓ Branch 0 taken 687642032 times.
✗ Branch 1 not taken.
687642032 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20812 {
20813 do_trigger_combo(lyr,pos);
20814 }
20815 687642032 }
20816 3907057 }
20817 558151 word c = tmpscr->numFFC();
20818
2/2
✓ Branch 0 taken 17767162 times.
✓ Branch 1 taken 558151 times.
18325313 for(word i=0; i<c; i++)
20819 {
20820 17767162 ffcdata& ffc = tmpscr->ffcs[i];
20821 17767162 newcombo const& cmb = combobuf[ffc.getData()];
20822
1/2
✓ Branch 0 taken 17767162 times.
✗ Branch 1 not taken.
17767162 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20823 {
20824 do_trigger_combo_ffc(i);
20825 }
20826 17767162 }
20827
1/2
✓ Branch 0 taken 558151 times.
✗ Branch 1 not taken.
558151 if(tmpscr->flags9 & fENEMY_WAVES)
20828 {
20829 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
20830 }
20831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558151 times.
558151 if(!hasmainguy)
20832 {
20833 // if room has traps, guys don't come back
20834
2/2
✓ Branch 0 taken 285773312 times.
✓ Branch 1 taken 558151 times.
286331463 for(int32_t i=0; i<eMAXGUYS; i++)
20835 {
20836
4/4
✓ Branch 0 taken 8372265 times.
✓ Branch 1 taken 277401047 times.
✓ Branch 2 taken 1116302 times.
✓ Branch 3 taken 7255963 times.
285773312 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
20837
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 1114078 times.
✓ Branch 2 taken 2223 times.
✓ Branch 3 taken 1 times.
1116303 if(guys.idCount(i) && !getmapflag(mTMPNORET))
20838 1 setmapflag(mTMPNORET);
20839 285773312 }
20840 // clear enemies and open secret
20841
4/4
✓ Branch 0 taken 502481 times.
✓ Branch 1 taken 55670 times.
✓ Branch 2 taken 502241 times.
✓ Branch 3 taken 240 times.
558151 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
20842 {
20843 240 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
20844 240 hidden_entrance(0,true,only16_31,-2);
20845
20846
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 237 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
240 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
20847 {
20848 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
20849 }
20850
20851 240 sfx(tmpscr->secretsfx);
20852 240 did_secret=true;
20853 240 }
20854 558151 }
20855 }
20856
20857 // doors
20858
2/2
✓ Branch 0 taken 1624990 times.
✓ Branch 1 taken 8366135 times.
9991125 for(int32_t i=0; i<4; i++)
20859
2/2
✓ Branch 0 taken 7552618 times.
✓ Branch 1 taken 813517 times.
8366135 if(tmpscr->door[i]==dSHUTTER)
20860 {
20861
4/4
✓ Branch 0 taken 801411 times.
✓ Branch 1 taken 12106 times.
✓ Branch 2 taken 425 times.
✓ Branch 3 taken 800986 times.
813517 if(opendoors==0 && loaded_enemies)
20862 {
20863
4/4
✓ Branch 0 taken 701438 times.
✓ Branch 1 taken 99548 times.
✓ Branch 2 taken 700675 times.
✓ Branch 3 taken 763 times.
800986 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
20864 763 opendoors=12;
20865 800986 }
20866
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 2474 times.
12531 else if(opendoors<0)
20867 2474 ++opendoors;
20868
2/2
✓ Branch 0 taken 9234 times.
✓ Branch 1 taken 823 times.
10057 else if((--opendoors)==0)
20869 823 openshutters();
20870
20871 813517 break;
20872 }
20873
20874 // set boss flag when boss is gone
20875
6/6
✓ Branch 0 taken 2405733 times.
✓ Branch 1 taken 32774 times.
✓ Branch 2 taken 31827 times.
✓ Branch 3 taken 2373906 times.
✓ Branch 4 taken 23770 times.
✓ Branch 5 taken 8057 times.
2438507 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
20876 {
20877 8057 game->lvlitems[dlevel]|=liBOSS;
20878 8057 stop_sfx(tmpscr->bosssfx);
20879 8057 }
20880
20881
1/2
✓ Branch 0 taken 2438507 times.
✗ Branch 1 not taken.
2438507 if(getmapflag(mCHEST)) // if special stuff done before
20882 {
20883 remove_chests((currscr>=128)?1:0);
20884 }
20885
20886
1/2
✓ Branch 0 taken 2438507 times.
✗ Branch 1 not taken.
2438507 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
20887 {
20888 remove_lockedchests((currscr>=128)?1:0);
20889 }
20890
20891
1/2
✓ Branch 0 taken 2438507 times.
✗ Branch 1 not taken.
2438507 if(getmapflag(mBOSSCHEST)) // if special stuff done before
20892 {
20893 remove_bosschests((currscr>=128)?1:0);
20894 }
20895
20896 2438507 clear_xstatecombos((currscr>=128)?1:0);
20897
20898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2438507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2438507 if((hasitem&8) && triggered_screen_secrets)
20899 {
20900 int32_t Item=tmpscr->item;
20901
20902 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20903 {
20904 items.add(new item((zfix)tmpscr->itemx,
20905 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20906 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20907 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20908 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20909 }
20910
20911 hasitem &= ~8;
20912 }
20913 2438507 }
20914
20915 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
20916 1161584 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
20917 {
20918 int32_t tmp;
20919 1161584 poses[0] = COMBOPOS(x1,y1);
20920
20921 1161584 tmp = COMBOPOS(x1,y2);
20922
2/2
✓ Branch 0 taken 913497 times.
✓ Branch 1 taken 248087 times.
1161584 if(tmp == poses[0])
20923 913497 poses[1] = -1;
20924 248087 else poses[1] = tmp;
20925
20926 1161584 tmp = COMBOPOS(x2,y1);
20927
3/4
✓ Branch 0 taken 481998 times.
✓ Branch 1 taken 679586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 481998 times.
1161584 if(tmp == poses[0] || tmp == poses[1])
20928 679586 poses[2] = -1;
20929 481998 else poses[2] = tmp;
20930
20931 1161584 tmp = COMBOPOS(x2,y2);
20932
6/6
✓ Branch 0 taken 628866 times.
✓ Branch 1 taken 532718 times.
✓ Branch 2 taken 481998 times.
✓ Branch 3 taken 146868 times.
✓ Branch 4 taken 380779 times.
✓ Branch 5 taken 101219 times.
1161584 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
20933 1060365 poses[3] = -1;
20934 101219 else poses[3] = tmp;
20935 1161584 }
20936
20937 2438227 void HeroClass::checkspecial2(int32_t *ls)
20938 {
20939
4/6
✓ Branch 0 taken 2428878 times.
✓ Branch 1 taken 9349 times.
✓ Branch 2 taken 2428878 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2428878 times.
2438227 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
20940 {
20941
2/2
✓ Branch 0 taken 740606 times.
✓ Branch 1 taken 1688272 times.
2428878 if(y.getInt()&7)
20942 740606 return;
20943
20944
2/2
✓ Branch 0 taken 1028254 times.
✓ Branch 1 taken 660018 times.
1688272 if(x.getInt()&7)
20945 1028254 return;
20946 660018 }
20947
20948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669367 times.
669367 if(toogam) return;
20949
20950 669367 bool didstrig = false;
20951
20952
2/2
✓ Branch 0 taken 1338734 times.
✓ Branch 1 taken 669367 times.
2008101 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
20953 {
20954
4/4
✓ Branch 0 taken 2677468 times.
✓ Branch 1 taken 1338734 times.
✓ Branch 2 taken 5354936 times.
✓ Branch 3 taken 2677468 times.
9371138 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
20955 {
20956
2/2
✓ Branch 0 taken 2677468 times.
✓ Branch 1 taken 2677468 times.
5354936 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
20957 5354936 int32_t stype = cmb.type;
20958 5354936 int32_t warpsound = cmb.attribytes[0];
20959
1/2
✓ Branch 0 taken 5354936 times.
✗ Branch 1 not taken.
5354936 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
20960 stype = cNONE;
20961
1/2
✓ Branch 0 taken 5354936 times.
✗ Branch 1 not taken.
5354936 if(stype==cSWARPA)
20962 {
20963 if(tmpscr->flags5&fDIRECTSWARP)
20964 {
20965 didpit=true;
20966 pitx=x;
20967 pity=y;
20968 }
20969
20970 sdir=dir;
20971 dowarp(0,0,warpsound);
20972 return;
20973 }
20974
20975
1/2
✓ Branch 0 taken 5354936 times.
✗ Branch 1 not taken.
5354936 if(stype==cSWARPB)
20976 {
20977 if(tmpscr->flags5&fDIRECTSWARP)
20978 {
20979 didpit=true;
20980 pitx=x;
20981 pity=y;
20982 }
20983
20984 sdir=dir;
20985 dowarp(0,1,warpsound);
20986 return;
20987 }
20988
20989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5354936 times.
5354936 if(stype==cSWARPC)
20990 {
20991 if(tmpscr->flags5&fDIRECTSWARP)
20992 {
20993 didpit=true;
20994 pitx=x;
20995 pity=y;
20996 }
20997
20998 sdir=dir;
20999 dowarp(0,2,warpsound);
21000 return;
21001 }
21002
21003
1/2
✓ Branch 0 taken 5354936 times.
✗ Branch 1 not taken.
5354936 if(stype==cSWARPD)
21004 {
21005 if(tmpscr->flags5&fDIRECTSWARP)
21006 {
21007 didpit=true;
21008 pitx=x;
21009 pity=y;
21010 }
21011
21012 sdir=dir;
21013 dowarp(0,3,warpsound);
21014 return;
21015 }
21016
21017
1/2
✓ Branch 0 taken 5354936 times.
✗ Branch 1 not taken.
5354936 if(stype==cSWARPR)
21018 {
21019 if(tmpscr->flags5&fDIRECTSWARP)
21020 {
21021 didpit=true;
21022 pitx=x;
21023 pity=y;
21024 }
21025
21026 sdir=dir;
21027 dowarp(0,(zc_oldrand()%4),warpsound);
21028 return;
21029 }
21030
21031
5/6
✓ Branch 0 taken 5354906 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5354906 times.
✓ Branch 4 taken 5354906 times.
✓ Branch 5 taken 30 times.
5354936 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=MAPCOMBO(x+j,y+i))
21032 {
21033 // zprint("Step Secs\n");
21034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if(stype==cSTRIGFLAG && canPermSecret())
21035 {
21036 if(!didstrig)
21037 {
21038 stepsecret = ((int32_t)(y+i)&0xF0)+((int32_t)(x+j)>>4);
21039
21040 if(!(tmpscr->flags5&fTEMPSECRETS))
21041 {
21042 setmapflag(mSECRET);
21043 }
21044 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21045 //zprint("Step Secrets SFX: %d\n", thesfx);
21046 sfx(warpsound,pan((int32_t)x));
21047 hidden_entrance(0,true,false);
21048 didstrig = true;
21049 }
21050 }
21051 else
21052 {
21053
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 13 times.
30 if(!didstrig)
21054 {
21055 13 stepsecret = ((int32_t)(y+i)&0xF0)+((int32_t)(x+j)>>4);
21056 13 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21057 13 hidden_entrance(0,true,only16_31);
21058 13 didstrig = true;
21059 //play trigger sound
21060 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21061 //zprint("Step Secrets SFX: %d\n", thesfx);
21062 //sfx(thesfx,pan((int32_t)x));
21063 13 sfx(warpsound,pan((int32_t)x));
21064 13 }
21065 }
21066 30 }
21067 8032404 }
21068 1338734 }
21069
21070 669367 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
21071
21072 // check if he's standing on a warp he just came out of
21073 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
21074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669367 times.
669367 if (!get_bit(quest_rules,qr_210_WARPRETURN))
21075 {
21076
6/6
✓ Branch 0 taken 668402 times.
✓ Branch 1 taken 965 times.
✓ Branch 2 taken 82982 times.
✓ Branch 3 taken 585420 times.
✓ Branch 4 taken 2869 times.
✓ Branch 5 taken 80113 times.
669367 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
21077 {
21078
5/6
✓ Branch 0 taken 79637 times.
✓ Branch 1 taken 476 times.
✓ Branch 2 taken 78872 times.
✓ Branch 3 taken 765 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 78872 times.
80113 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
21079 {
21080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78872 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21081 78872 else return;
21082 }
21083 1241 }
21084 590495 }
21085 else
21086 {
21087 if((int(y)&0xF8)==warpy)
21088 {
21089 if(x==warpx)
21090 {
21091 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21092 else return;
21093 }
21094 }
21095 }
21096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 590495 times.
590495 if (!RaftPass) warpy=-1;
21097
21098
6/6
✓ Branch 0 taken 588952 times.
✓ Branch 1 taken 1543 times.
✓ Branch 2 taken 31892 times.
✓ Branch 3 taken 557060 times.
✓ Branch 4 taken 29030 times.
✓ Branch 5 taken 2862 times.
590495 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
21099 {
21100 561465 raftwarpy = -1;
21101 561465 }
21102
6/6
✓ Branch 0 taken 589420 times.
✓ Branch 1 taken 1075 times.
✓ Branch 2 taken 32359 times.
✓ Branch 3 taken 557061 times.
✓ Branch 4 taken 30357 times.
✓ Branch 5 taken 2002 times.
590495 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
21103 {
21104 560138 raftwarpx = -1;
21105 560138 }
21106 590495 int32_t tx=x;
21107 590495 int32_t ty=y;
21108
21109 590495 int32_t flag=0;
21110 590495 int32_t flag2=0;
21111 590495 int32_t flag3=0;
21112 590495 int32_t type=0;
21113 590495 int32_t water=0;
21114 590495 int32_t index = 0;
21115
21116 590495 bool setsave=false;
21117 590495 int32_t warpsfx2 = 0;
21118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 590495 times.
590495 if (RaftPass) goto RaftingStuff;
21119
21120 //bool gotpit=false;
21121
21122 int32_t x1,x2,y1,y2;
21123 590495 x1 = tx;
21124 590495 x2 = tx+15;
21125 590495 y1 = ty;
21126 590495 y2 = ty+15;
21127
21128
3/4
✓ Branch 0 taken 581254 times.
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 581254 times.
590495 if((diagonalMovement||NO_GRIDLOCK))
21129 {
21130 9241 x1 = tx+4;
21131 9241 x2 = tx+11;
21132 9241 y1 = ty+4;
21133 9241 y2 = ty+11;
21134 9241 }
21135
21136 int32_t types[4];
21137 590495 types[0]=types[1]=types[2]=types[3]=-1;
21138 int32_t cids[4];
21139 int32_t ffcids[4];
21140 590495 cids[0]=cids[1]=cids[2]=cids[3]=-1;
21141 590495 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
21142 //
21143 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
21144 //
21145 590495 types[0] = MAPFLAG(x1,y1);
21146 590495 types[1] = MAPFLAG(x1,y2);
21147 590495 types[2] = MAPFLAG(x2,y1);
21148 590495 types[3] = MAPFLAG(x2,y2);
21149
21150
21151 //MAPFFCOMBO
21152
21153
21154
6/6
✓ Branch 0 taken 569675 times.
✓ Branch 1 taken 20820 times.
✓ Branch 2 taken 567870 times.
✓ Branch 3 taken 1805 times.
✓ Branch 4 taken 1195 times.
✓ Branch 5 taken 566675 times.
590495 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21155 566675 flag = types[0];
21156
21157 // 2.10 compatibility...
21158
8/10
✓ Branch 0 taken 22629 times.
✓ Branch 1 taken 1191 times.
✓ Branch 2 taken 19577 times.
✓ Branch 3 taken 3052 times.
✓ Branch 4 taken 10811 times.
✓ Branch 5 taken 8766 times.
✓ Branch 6 taken 10811 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 10811 times.
23820 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
21159 8766 flag = types[0];
21160
21161
21162 590495 types[0] = MAPCOMBOFLAG(x1,y1);
21163 590495 types[1] = MAPCOMBOFLAG(x1,y2);
21164 590495 types[2] = MAPCOMBOFLAG(x2,y1);
21165 590495 types[3] = MAPCOMBOFLAG(x2,y2);
21166
21167
6/6
✓ Branch 0 taken 590142 times.
✓ Branch 1 taken 353 times.
✓ Branch 2 taken 590134 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 590034 times.
590495 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21168 590034 flag2 = types[0];
21169
21170 590495 types[0] = MAPFFCOMBOFLAG(x1,y1);
21171 590495 types[1] = MAPFFCOMBOFLAG(x1,y2);
21172 590495 types[2] = MAPFFCOMBOFLAG(x2,y1);
21173 590495 types[3] = MAPFFCOMBOFLAG(x2,y2);
21174
21175
21176 //
21177
21178
6/6
✓ Branch 0 taken 590490 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 590483 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 590482 times.
590495 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21179 590482 flag3 = types[0];
21180
21181 //
21182 // Now, let's check for warp combos...
21183 //
21184
21185 //
21186
21187 590495 cids[0] = MAPCOMBO(x1,y1);
21188 590495 cids[1] = MAPCOMBO(x1,y2);
21189 590495 cids[2] = MAPCOMBO(x2,y1);
21190 590495 cids[3] = MAPCOMBO(x2,y2);
21191
21192 590495 types[0] = COMBOTYPE(x1,y1);
21193
21194
2/2
✓ Branch 0 taken 589174 times.
✓ Branch 1 taken 1321 times.
590495 if(MAPFFCOMBO(x1,y1))
21195 {
21196 1321 types[0] = FFCOMBOTYPE(x1,y1);
21197 1321 cids[0] = MAPFFCOMBO(x1,y1);
21198 1321 }
21199
21200 590495 types[1] = COMBOTYPE(x1,y2);
21201
21202
2/2
✓ Branch 0 taken 589420 times.
✓ Branch 1 taken 1075 times.
590495 if(MAPFFCOMBO(x1,y2))
21203 {
21204 1075 types[1] = FFCOMBOTYPE(x1,y2);
21205 1075 cids[1] = MAPFFCOMBO(x1,y2);
21206 1075 }
21207
21208 590495 types[2] = COMBOTYPE(x2,y1);
21209
21210
2/2
✓ Branch 0 taken 589385 times.
✓ Branch 1 taken 1110 times.
590495 if(MAPFFCOMBO(x2,y1))
21211 {
21212 1110 types[2] = FFCOMBOTYPE(x2,y1);
21213 1110 cids[2] = MAPFFCOMBO(x2,y1);
21214 1110 }
21215 590495 types[3] = COMBOTYPE(x2,y2);
21216
21217
2/2
✓ Branch 0 taken 589705 times.
✓ Branch 1 taken 790 times.
590495 if(MAPFFCOMBO(x2,y2))
21218 {
21219 790 types[3] = FFCOMBOTYPE(x2,y2);
21220 790 cids[3] = MAPFFCOMBO(x2,y2);
21221 790 }
21222 // Change B, C and D warps into A, for the comparison below...
21223
2/2
✓ Branch 0 taken 2361980 times.
✓ Branch 1 taken 590495 times.
2952475 for(int32_t i=0; i<4; i++)
21224 {
21225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361980 times.
2361980 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21226 {
21227 types[i] = cNONE;
21228 continue;
21229 }
21230
2/2
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 2360599 times.
2361980 if(types[i]==cCAVE)
21231 {
21232 1381 index=0;
21233 1381 warpsfx2 = combobuf[cids[i]].attribytes[0];
21234 1381 }
21235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2360599 times.
2360599 else if(types[i]==cCAVEB)
21236 {
21237 types[i]=cCAVE;
21238 index=1;
21239 warpsfx2 = combobuf[cids[i]].attribytes[0];
21240 }
21241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2360599 times.
2360599 else if(types[i]==cCAVEC)
21242 {
21243 types[i]=cCAVE;
21244 index=2;
21245 warpsfx2 = combobuf[cids[i]].attribytes[0];
21246 }
21247
1/2
✓ Branch 0 taken 2360599 times.
✗ Branch 1 not taken.
2360599 else if(types[i]==cCAVED)
21248 {
21249 types[i]=cCAVE;
21250 index=3;
21251 warpsfx2 = combobuf[cids[i]].attribytes[0];
21252 }
21253
21254
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 2361856 times.
2361980 if(types[i]==cPIT)
21255 {
21256 124 index=0;
21257 124 warpsfx2 = combobuf[cids[i]].attribytes[0];
21258 124 }
21259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361856 times.
2361856 else if(types[i]==cPITB)
21260 {
21261 types[i]=cPIT;
21262 warpsfx2 = combobuf[cids[i]].attribytes[0];
21263 index=1;
21264 }
21265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361856 times.
2361856 else if(types[i]==cPITC)
21266 {
21267 types[i]=cPIT;
21268 warpsfx2 = combobuf[cids[i]].attribytes[0];
21269 index=2;
21270 }
21271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361856 times.
2361856 else if(types[i]==cPITD)
21272 {
21273 types[i]=cPIT;
21274 warpsfx2 = combobuf[cids[i]].attribytes[0];
21275 index=3;
21276 }
21277
1/2
✓ Branch 0 taken 2361856 times.
✗ Branch 1 not taken.
2361856 else if(types[i]==cPITR)
21278 {
21279 types[i]=cPIT;
21280 warpsfx2 = combobuf[cids[i]].attribytes[0];
21281 index=zc_oldrand()%4;
21282 }
21283
21284
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 2357660 times.
2361980 if(types[i]==cSTAIR)
21285 {
21286 4320 index=0;
21287 4320 warpsfx2 = combobuf[cids[i]].attribytes[0];
21288 4320 }
21289
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2357654 times.
2357660 else if(types[i]==cSTAIRB)
21290 {
21291 6 types[i]=cSTAIR;
21292 6 warpsfx2 = combobuf[cids[i]].attribytes[0];
21293 6 index=1;
21294 6 }
21295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2357654 times.
2357654 else if(types[i]==cSTAIRC)
21296 {
21297 types[i]=cSTAIR;
21298 warpsfx2 = combobuf[cids[i]].attribytes[0];
21299 index=2;
21300 }
21301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2357654 times.
2357654 else if(types[i]==cSTAIRD)
21302 {
21303 types[i]=cSTAIR;
21304 warpsfx2 = combobuf[cids[i]].attribytes[0];
21305 index=3;
21306 }
21307
1/2
✓ Branch 0 taken 2357654 times.
✗ Branch 1 not taken.
2357654 else if(types[i]==cSTAIRR)
21308 {
21309 types[i]=cSTAIR;
21310 index=zc_oldrand()%4;
21311 warpsfx2 = combobuf[cids[i]].attribytes[0];
21312 }
21313
21314
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 2361753 times.
2361980 if(types[i]==cCAVE2)
21315 {
21316 227 index=0;
21317 227 warpsfx2 = combobuf[cids[i]].attribytes[0];
21318 227 }
21319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361753 times.
2361753 else if(types[i]==cCAVE2B)
21320 {
21321 types[i]=cCAVE2;
21322 index=1;
21323 warpsfx2 = combobuf[cids[i]].attribytes[0];
21324 }
21325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361753 times.
2361753 else if(types[i]==cCAVE2C)
21326 {
21327 types[i]=cCAVE2;
21328 warpsfx2 = combobuf[cids[i]].attribytes[0];
21329 index=2;
21330 }
21331
1/2
✓ Branch 0 taken 2361753 times.
✗ Branch 1 not taken.
2361753 else if(types[i]==cCAVE2D)
21332 {
21333 types[i]=cCAVE2;
21334 warpsfx2 = combobuf[cids[i]].attribytes[0];
21335 index=3;
21336 }
21337
21338
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2361968 times.
2361980 if(types[i]==cSWIMWARP)
21339 {
21340 12 index=0;
21341 12 warpsfx2 = combobuf[cids[i]].attribytes[0];
21342 12 }
21343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361968 times.
2361968 else if(types[i]==cSWIMWARPB)
21344 {
21345 types[i]=cSWIMWARP;
21346 warpsfx2 = combobuf[cids[i]].attribytes[0];
21347 index=1;
21348 }
21349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361968 times.
2361968 else if(types[i]==cSWIMWARPC)
21350 {
21351 types[i]=cSWIMWARP;
21352 warpsfx2 = combobuf[cids[i]].attribytes[0];
21353 index=2;
21354 }
21355
1/2
✓ Branch 0 taken 2361968 times.
✗ Branch 1 not taken.
2361968 else if(types[i]==cSWIMWARPD)
21356 {
21357 types[i]=cSWIMWARP;
21358 warpsfx2 = combobuf[cids[i]].attribytes[0];
21359 index=3;
21360 }
21361
21362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361980 times.
2361980 if(types[i]==cDIVEWARP)
21363 {
21364 index=0;
21365 warpsfx2 = combobuf[cids[i]].attribytes[0];
21366 }
21367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361980 times.
2361980 else if(types[i]==cDIVEWARPB)
21368 {
21369 types[i]=cDIVEWARP;
21370 warpsfx2 = combobuf[cids[i]].attribytes[0];
21371 index=1;
21372 }
21373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361980 times.
2361980 else if(types[i]==cDIVEWARPC)
21374 {
21375 types[i]=cDIVEWARP;
21376 warpsfx2 = combobuf[cids[i]].attribytes[0];
21377 index=2;
21378 }
21379
1/2
✓ Branch 0 taken 2361980 times.
✗ Branch 1 not taken.
2361980 else if(types[i]==cDIVEWARPD)
21380 {
21381 types[i]=cDIVEWARP;
21382 warpsfx2 = combobuf[cids[i]].attribytes[0];
21383 index=3;
21384 }
21385
21386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361980 times.
2361980 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
21387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361980 times.
2361980 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
21388
1/2
✓ Branch 0 taken 2361980 times.
✗ Branch 1 not taken.
2361980 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
21389 2361980 }
21390
21391 // Special case for step combos; otherwise, they act oddly in some cases
21392
7/8
✓ Branch 0 taken 537606 times.
✓ Branch 1 taken 52889 times.
✓ Branch 2 taken 530640 times.
✓ Branch 3 taken 6966 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 59855 times.
✓ Branch 6 taken 5500 times.
✓ Branch 7 taken 5500 times.
590495 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
21393 {
21394
6/8
✓ Branch 0 taken 516233 times.
✓ Branch 1 taken 8907 times.
✓ Branch 2 taken 516233 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 171 times.
✓ Branch 5 taken 516062 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 171 times.
536140 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21395 516233 type = types[1];
21396 525140 }
21397
21398 //Generic Step
21399
6/8
✓ Branch 0 taken 580792 times.
✓ Branch 1 taken 9703 times.
✓ Branch 2 taken 580792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 171 times.
✓ Branch 5 taken 580621 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 171 times.
590495 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21400 {
21401 int32_t poses[4];
21402 int32_t sensPoses[4];
21403 580792 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
21404 580792 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
21405
3/4
✓ Branch 0 taken 571551 times.
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 571551 times.
580792 if(diagonalMovement||NO_GRIDLOCK)
21406 9241 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
21407 571551 else getPoses(poses, tx, ty, tx+15, ty+15);
21408 580792 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
21409 580792 bool hasStep[4] = {false};
21410
2/2
✓ Branch 0 taken 2323168 times.
✓ Branch 1 taken 580792 times.
2903960 for(auto p = 0; p < 4; ++p)
21411 {
21412
2/2
✓ Branch 0 taken 2323168 times.
✓ Branch 1 taken 16262176 times.
18585344 for(auto lyr = 0; lyr < 7; ++lyr)
21413 {
21414
2/2
✓ Branch 0 taken 8156421 times.
✓ Branch 1 taken 8105755 times.
16262176 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21415
3/4
✓ Branch 0 taken 8156421 times.
✓ Branch 1 taken 8105755 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16262176 times.
16262176 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
21416 16262176 || types[p] == cSTEP)
21417 {
21418 hasStep[p] = true;
21419 break;
21420 }
21421 16262176 }
21422 2323168 }
21423 580792 bool canNormalStep = true;
21424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580792 times.
580792 for(auto p = 0; p < 4; ++p)
21425 {
21426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580792 times.
580792 if(poses[p] < 0) continue;
21427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580792 times.
580792 if(!hasStep[p])
21428 {
21429 580792 canNormalStep = false;
21430 580792 break;
21431 }
21432 }
21433
2/2
✓ Branch 0 taken 2323168 times.
✓ Branch 1 taken 580792 times.
2903960 for(auto p = 0; p < 4; ++p)
21434 {
21435
2/2
✓ Branch 0 taken 16262176 times.
✓ Branch 1 taken 2323168 times.
18585344 for(auto lyr = 0; lyr < 7; ++lyr)
21436 {
21437
2/2
✓ Branch 0 taken 8156421 times.
✓ Branch 1 taken 8105755 times.
16262176 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21438
2/2
✓ Branch 0 taken 5793795 times.
✓ Branch 1 taken 10468381 times.
16262176 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
21439
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16262176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16262176 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
21440 {
21441 do_trigger_combo(lyr,poses[p]);
21442 if(poses[p] == sensPoses[p]) continue;
21443 }
21444
3/4
✓ Branch 0 taken 5793795 times.
✓ Branch 1 taken 10468381 times.
✓ Branch 2 taken 5793795 times.
✗ Branch 3 not taken.
16262176 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
21445 {
21446 do_trigger_combo(lyr,sensPoses[p]);
21447 }
21448 16262176 }
21449 2323168 }
21450 580792 word c = tmpscr->numFFC();
21451
2/2
✓ Branch 0 taken 18436161 times.
✓ Branch 1 taken 580792 times.
19016953 for(word i=0; i<c; i++)
21452 {
21453 18436161 bool found = false;
21454
2/2
✓ Branch 0 taken 36872322 times.
✓ Branch 1 taken 18436161 times.
55308483 for(auto xch = 0; xch < 2; ++xch)
21455 {
21456
2/2
✓ Branch 0 taken 73744644 times.
✓ Branch 1 taken 36872322 times.
110616966 for(auto ych = 0; ych < 2; ++ych)
21457 {
21458
2/2
✓ Branch 0 taken 73739461 times.
✓ Branch 1 taken 5183 times.
73744644 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
21459 {
21460 5183 found = true;
21461 5183 }
21462 73744644 }
21463 36872322 }
21464
2/2
✓ Branch 0 taken 18433928 times.
✓ Branch 1 taken 2233 times.
18436161 if (found)
21465 {
21466 2233 ffcdata& ffc = tmpscr->ffcs[i];
21467 2233 newcombo const* cmb = &combobuf[ffc.getData()];
21468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2233 times.
2233 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
21469 {
21470 do_trigger_combo_ffc(i);
21471 }
21472 2233 }
21473 18436161 }
21474 580792 }
21475
21476 //
21477 // Now, let's check for Save combos...
21478 //
21479 590495 x1 = tx+4;
21480 590495 x2 = tx+11;
21481 590495 y1 = ty+4;
21482 590495 y2 = ty+11;
21483
21484 590495 types[0] = COMBOTYPE(x1,y1);
21485 590495 cids[0] = MAPCOMBO(x1,y1);
21486
21487
2/2
✓ Branch 0 taken 589197 times.
✓ Branch 1 taken 1298 times.
590495 if(MAPFFCOMBO(x1,y1))
21488 {
21489 1298 types[0] = FFCOMBOTYPE(x1,y1);
21490 1298 cids[0] = MAPFFCOMBO(x1,y1);
21491 1298 }
21492
21493 590495 types[1] = COMBOTYPE(x1,y2);
21494 590495 cids[1] = MAPCOMBO(x1,y2);
21495
21496
2/2
✓ Branch 0 taken 589406 times.
✓ Branch 1 taken 1089 times.
590495 if(MAPFFCOMBO(x1,y2))
21497 {
21498 1089 types[1] = FFCOMBOTYPE(x1,y2);
21499 1089 cids[1] = MAPFFCOMBO(x1,y2);
21500 1089 }
21501
21502 590495 types[2] = COMBOTYPE(x2,y1);
21503 590495 cids[2] = MAPCOMBO(x2,y1);
21504
21505
2/2
✓ Branch 0 taken 589400 times.
✓ Branch 1 taken 1095 times.
590495 if(MAPFFCOMBO(x2,y1))
21506 {
21507 1095 types[2] = FFCOMBOTYPE(x2,y1);
21508 1095 cids[2] = MAPFFCOMBO(x2,y1);
21509 1095 }
21510
21511 590495 types[3] = COMBOTYPE(x2,y2);
21512 590495 cids[3] = MAPCOMBO(x2,y2);
21513
21514
2/2
✓ Branch 0 taken 589690 times.
✓ Branch 1 taken 805 times.
590495 if(MAPFFCOMBO(x2,y2))
21515 {
21516 805 types[3] = FFCOMBOTYPE(x2,y2);
21517 805 cids[3] = MAPFFCOMBO(x2,y2);
21518 805 }
21519
21520
21521
2/2
✓ Branch 0 taken 590495 times.
✓ Branch 1 taken 2361980 times.
2952475 for(int32_t i=0; i<4; i++)
21522 {
21523
1/2
✓ Branch 0 taken 2361980 times.
✗ Branch 1 not taken.
2361980 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21524 {
21525 if(types[i] == cSAVE || types[i] == cSAVE2)
21526 {
21527 types[i] = cNONE;
21528 setsave = false;
21529 break;
21530 }
21531 }
21532
1/2
✓ Branch 0 taken 2361980 times.
✗ Branch 1 not taken.
2361980 if(types[i]==cSAVE) setsave=true;
21533
21534
1/2
✓ Branch 0 taken 2361980 times.
✗ Branch 1 not taken.
2361980 if(types[i]==cSAVE2) setsave=true;
21535 2361980 }
21536
21537
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 590495 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
590495 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21538 {
21539 last_savepoint_id = cids[0];
21540 type = types[0];
21541 }
21542 //
21543 // Now, let's check for Drowning combos...
21544 //
21545
3/4
✓ Branch 0 taken 581254 times.
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 581254 times.
590495 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
21546 {
21547 9241 y1 = ty+9;
21548 9241 y2 = ty+15;
21549
1/2
✓ Branch 0 taken 9241 times.
✗ Branch 1 not taken.
9241 if (get_bit(quest_rules, qr_SMARTER_WATER))
21550 {
21551
3/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 9185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
9281 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
21552
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 16 times.
56 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
21553
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
21554 40 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
21555 9241 }
21556 else
21557 {
21558 types[0] = COMBOTYPE(x1,y1);
21559
21560 if(MAPFFCOMBO(x1,y1))
21561 types[0] = FFCOMBOTYPE(x1,y1);
21562
21563 types[1] = COMBOTYPE(x1,y2);
21564
21565 if(MAPFFCOMBO(x1,y2))
21566 types[1] = FFCOMBOTYPE(x1,y2);
21567
21568 types[2] = COMBOTYPE(x2,y1);
21569
21570 if(MAPFFCOMBO(x2,y1))
21571 types[2] = FFCOMBOTYPE(x2,y1);
21572
21573 types[3] = COMBOTYPE(x2,y2);
21574
21575 if(MAPFFCOMBO(x2,y2))
21576 types[3] = FFCOMBOTYPE(x2,y2);
21577
21578 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
21579 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
21580 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
21581
21582 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
21583 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
21584 water = typec;
21585 }
21586 9241 }
21587
21588
21589 // Pits have a bigger 'hitbox' than stairs...
21590 590495 x1 = tx+7;
21591 590495 x2 = tx+8;
21592 590495 y1 = ty+7+(bigHitbox?0:4);
21593 590495 y2 = ty+8+(bigHitbox?0:4);
21594
21595 590495 types[0] = COMBOTYPE(x1,y1);
21596 590495 cids[0] = MAPCOMBO(x1,y1);
21597
21598
2/2
✓ Branch 0 taken 589491 times.
✓ Branch 1 taken 1004 times.
590495 if(MAPFFCOMBO(x1,y1))
21599 {
21600 1004 types[0] = FFCOMBOTYPE(x1,y1);
21601 1004 cids[0] = MAPFFCOMBO(x1,y1);
21602 1004 }
21603
21604 590495 types[1] = COMBOTYPE(x1,y2);
21605 590495 cids[1] = MAPCOMBO(x1,y2);
21606
21607
2/2
✓ Branch 0 taken 589508 times.
✓ Branch 1 taken 987 times.
590495 if(MAPFFCOMBO(x1,y2))
21608 {
21609 987 types[1] = FFCOMBOTYPE(x1,y2);
21610 987 cids[1] = MAPFFCOMBO(x1,y2);
21611 987 }
21612 590495 types[2] = COMBOTYPE(x2,y1);
21613 590495 cids[2] = MAPCOMBO(x2,y1);
21614
21615
2/2
✓ Branch 0 taken 589650 times.
✓ Branch 1 taken 845 times.
590495 if(MAPFFCOMBO(x2,y1))
21616 {
21617 845 types[2] = FFCOMBOTYPE(x2,y1);
21618 845 cids[2] = MAPFFCOMBO(x2,y1);
21619 845 }
21620
21621 590495 types[3] = COMBOTYPE(x2,y2);
21622 590495 cids[3] = MAPCOMBO(x2,y2);
21623
21624
2/2
✓ Branch 0 taken 589668 times.
✓ Branch 1 taken 827 times.
590495 if(MAPFFCOMBO(x2,y2))
21625 {
21626 827 types[3] = FFCOMBOTYPE(x2,y2);
21627 827 cids[3] = MAPFFCOMBO(x2,y2);
21628 827 }
21629
21630
2/2
✓ Branch 0 taken 2361980 times.
✓ Branch 1 taken 590495 times.
2952475 for(int32_t i=0; i<4; i++)
21631 {
21632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361980 times.
2361980 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21633 {
21634 types[i] = cNONE;
21635 continue;
21636 }
21637
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 2361854 times.
2361980 if(types[i]==cPIT)
21638 {
21639 126 index=0;
21640 126 warpsfx2 = combobuf[cids[i]].attribytes[0];
21641 126 }
21642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361854 times.
2361854 else if(types[i]==cPITB)
21643 {
21644 types[i]=cPIT;
21645 index=1;
21646 warpsfx2 = combobuf[cids[i]].attribytes[0];
21647 }
21648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361854 times.
2361854 else if(types[i]==cPITC)
21649 {
21650 types[i]=cPIT;
21651 index=2;
21652 warpsfx2 = combobuf[cids[i]].attribytes[0];
21653 }
21654
1/2
✓ Branch 0 taken 2361854 times.
✗ Branch 1 not taken.
2361854 else if(types[i]==cPITD)
21655 {
21656 types[i]=cPIT;
21657 index=3;
21658 warpsfx2 = combobuf[cids[i]].attribytes[0];
21659 }
21660 2361980 }
21661
21662
6/8
✓ Branch 0 taken 590464 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 590464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 590463 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 590463 times.
590495 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
21663
3/8
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
64 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21664 32 type=cPIT;
21665
21666 //
21667 // Time to act on our results for type, flag, flag2 and flag3...
21668 //
21669
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 590495 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
590495 if(type==cSAVE&&currscr<128)
21670 *ls=1;
21671
21672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 590495 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
590495 if(type==cSAVE2&&currscr<128)
21673 *ls=2;
21674
21675
6/8
✓ Branch 0 taken 585085 times.
✓ Branch 1 taken 5410 times.
✓ Branch 2 taken 579169 times.
✓ Branch 3 taken 5916 times.
✓ Branch 4 taken 579169 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 579169 times.
590495 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
21676 {
21677 11326 fairycircle(REFILL_LIFE);
21678
21679
2/2
✓ Branch 0 taken 9703 times.
✓ Branch 1 taken 1623 times.
11326 if(fairyclk!=0) return;
21680 1623 }
21681
21682
4/8
✓ Branch 0 taken 580792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 580792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 580792 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 580792 times.
580792 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
21683 {
21684 fairycircle(REFILL_MAGIC);
21685
21686 if(fairyclk!=0) return;
21687 }
21688
21689
4/8
✓ Branch 0 taken 580792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 580792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 580792 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 580792 times.
580792 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
21690 {
21691 fairycircle(REFILL_ALL);
21692
21693 if(fairyclk!=0) return;
21694 }
21695
21696 // Just in case Hero was moved off of the fairy flag
21697
1/2
✓ Branch 0 taken 580792 times.
✗ Branch 1 not taken.
580792 if(refilling==REFILL_FAIRYDONE)
21698 {
21699 fairycircle(REFILL_NONE);
21700
21701 if(fairyclk!=0) return;
21702 }
21703
21704
5/8
✓ Branch 0 taken 580790 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 580790 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 580790 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 580790 times.
580792 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
21705 {
21706 2 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
21707 2 win_game();
21708 2 return;
21709 }
21710
21711
4/4
✓ Branch 0 taken 580670 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 580670 times.
✓ Branch 3 taken 120 times.
580790 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
21712 120 return;
21713
21714
2/4
✓ Branch 0 taken 580670 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 580670 times.
580670 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
21715 {
21716
21717 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
21718 {
21719 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
21720 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
21721 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
21722
21723 if(type==cTRIGFLAG && canPermSecret())
21724 {
21725 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
21726
21727 hidden_entrance(0,true,false);
21728 }
21729 else
21730 {
21731 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21732 hidden_entrance(0,true,only16_31);
21733 }
21734 }
21735 }
21736
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 580658 times.
580670 else if(!didstrig)
21737 {
21738 580658 stepsecret = -1;
21739 580658 }
21740
21741 //Better? Dock collision
21742
21743 // Drown if:
21744 // * Water (obviously walkable),
21745 // * Quest Rule allows it,
21746 // * Not on stepladder,
21747 // * Not jumping,
21748 // * Not hovering,
21749 // * Not rafting,
21750 // * Not swallowed,
21751 // * Not a dried lake.
21752
21753 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
21754
21755
10/22
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 580667 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
580670 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
21756 {
21757
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
21758 {
21759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(ladderx+laddery)) drownCombo = water;
21760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (combobuf[water].usrflags&cflag1) Drown(1);
21761 3 else Drown();
21762
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(byte drown_sfx = combobuf[water].attribytes[4])
21763 sfx(drown_sfx, pan(int32_t(x)));
21764 3 }
21765 else if (!isSwimming())
21766 {
21767 SetSwim();
21768 if (!IsSideSwim()) attackclk = charging = spins = 0;
21769 landswim=0;
21770 return;
21771 }
21772 3 }
21773
21774
21775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580670 times.
580670 if(type==cSTEP)
21776 {
21777 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
21778 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
21779 {
21780 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
21781
21782 if
21783 (
21784 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
21785 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
21786 && /*HEAVY*/
21787 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21788 )
21789
21790 {
21791 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
21792 tmpscr->data[stepnext]++;
21793
21794 }
21795
21796 if
21797 (
21798 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
21799 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21800 && /*HEAVY*/
21801 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21802 )
21803 {
21804 int32_t stepc = tmpscr->data[stepnext];
21805 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21806 for(int32_t k=0; k<176; k++)
21807 {
21808 if(tmpscr->data[k]==stepc)
21809 {
21810 tmpscr->data[k]++;
21811 }
21812 }
21813 }
21814
21815 if
21816 (
21817 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
21818 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21819 && /*HEAVY*/
21820 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21821 )
21822 {
21823 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21824 for(int32_t k=0; k<176; k++)
21825 {
21826 if(
21827 (combobuf[tmpscr->data[k]].type==cSTEP)||
21828 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
21829 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
21830 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
21831 )
21832 {
21833 tmpscr->data[k]++;
21834 }
21835 }
21836 }
21837 }
21838 }
21839
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 580670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
580670 else if(type==cSTEPSFX && action == walking)
21840 {
21841 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
21842 }
21843 580670 else stepnext = -1;
21844
21845 580670 detail_int[0]=tx;
21846 580670 detail_int[1]=ty;
21847
21848
21849
6/8
✓ Branch 0 taken 580553 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 139 times.
✓ Branch 3 taken 580531 times.
✓ Branch 4 taken 580084 times.
✓ Branch 5 taken 447 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
580670 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
21850
5/6
✓ Branch 0 taken 580052 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 580050 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 580050 times.
✗ Branch 5 not taken.
580084 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
21851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580050 times.
580050 !(type==cDIVEWARP && isDiving()))
21852 580050 {
21853 RaftingStuff:
21854
1/2
✓ Branch 0 taken 580050 times.
✗ Branch 1 not taken.
580050 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
21855 {
21856 bool doraft = true;
21857 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
21858 {
21859 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21860 {
21861 doraft = false;
21862 }
21863 }
21864 //if (mfRAFT)
21865 int32_t rafttypes[2];
21866 int32_t raftx1 = tx+6;
21867 int32_t raftx2 = tx+9;
21868 int32_t rafty = ty+11;
21869 int32_t raftflags[3];
21870 rafttypes[0]=rafttypes[1]=-1;
21871 raftflags[0]=raftflags[1]=raftflags[2]=0;
21872 rafttypes[0] = MAPFLAG(raftx1,rafty);
21873 rafttypes[1] = MAPFLAG(raftx2,rafty);
21874
21875 if(rafttypes[0]==rafttypes[1])
21876 raftflags[0] = rafttypes[0];
21877
21878
21879 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
21880 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
21881
21882 if(rafttypes[0]==rafttypes[1])
21883 raftflags[1] = rafttypes[0];
21884
21885 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
21886 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
21887
21888 if(rafttypes[0]==rafttypes[1])
21889 raftflags[2] = rafttypes[0];
21890
21891 for (int32_t m = 0; m < 3; ++m)
21892 {
21893 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
21894 {
21895 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
21896 {
21897 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
21898 {
21899 reset_swordcharge();
21900 action=rafting; FFCore.setHeroAction(rafting);
21901 raftclk=0;
21902 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21903 else sfx(tmpscr->secretsfx);
21904 }
21905 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21906 {
21907 for (int32_t i = 0; i < 4; ++i)
21908 {
21909 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
21910 {
21911 reset_swordcharge();
21912 action=rafting; FFCore.setHeroAction(rafting);
21913 raftclk=0;
21914 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21915 else sfx(tmpscr->secretsfx);
21916 dir = i;
21917 break;
21918 }
21919 }
21920 }
21921 }
21922 }
21923 }
21924 }
21925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580050 times.
580050 if (RaftPass) return;
21926
3/3
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 577861 times.
✓ Branch 2 taken 134 times.
580050 switch(flag)
21927 {
21928 case mfDIVE_ITEM:
21929
6/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
134 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21930 {
21931 4 additem(x, y, tmpscr->catchall,
21932 2 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21933 2 sfx(tmpscr->secretsfx);
21934 2 }
21935
21936 134 return;
21937
21938 case mfRAFT:
21939 case mfRAFT_BRANCH:
21940
21941 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
2055 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21943 {
21944 2055 bool doraft = true;
21945
5/6
✓ Branch 0 taken 2055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✓ Branch 3 taken 1675 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 317 times.
2055 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21946 {
21947
4/6
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 304 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
317 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21948 {
21949 doraft = false;
21950 }
21951 317 }
21952
12/16
✓ Branch 0 taken 1858 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 1567 times.
✓ Branch 4 taken 291 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 289 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 289 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 289 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 289 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 138 times.
✓ Branch 15 taken 151 times.
2055 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21953 {
21954
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
151 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
21955 {
21956 111 reset_swordcharge();
21957 111 action=rafting; FFCore.setHeroAction(rafting);
21958 111 raftclk=0;
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21960 111 else sfx(tmpscr->secretsfx);
21961 111 }
21962
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21963 {
21964 for (int32_t i = 0; i < 4; ++i)
21965 {
21966 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21967 {
21968 reset_swordcharge();
21969 action=rafting; FFCore.setHeroAction(rafting);
21970 raftclk=0;
21971 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21972 else sfx(tmpscr->secretsfx);
21973 dir = i;
21974 break;
21975 }
21976 }
21977 }
21978 151 }
21979 2055 }
21980
21981 2055 return;
21982
21983 default:
21984 577861 break;
21985 //return;
21986 }
21987
21988
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 577861 times.
✗ Branch 2 not taken.
577861 switch(flag2)
21989 {
21990 case mfDIVE_ITEM:
21991 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21992 {
21993 additem(x, y, tmpscr->catchall,
21994 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21995 sfx(tmpscr->secretsfx);
21996 }
21997
21998 return;
21999
22000 case mfRAFT:
22001 case mfRAFT_BRANCH:
22002
22003 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22004 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22005 {
22006 bool doraft = true;
22007 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22008 {
22009 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22010 {
22011 doraft = false;
22012 }
22013 }
22014 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22015 {
22016 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22017 {
22018 reset_swordcharge();
22019 action=rafting; FFCore.setHeroAction(rafting);
22020 raftclk=0;
22021 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22022 else sfx(tmpscr->secretsfx);
22023 }
22024 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22025 {
22026 for (int32_t i = 0; i < 4; ++i)
22027 {
22028 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22029 {
22030 reset_swordcharge();
22031 action=rafting; FFCore.setHeroAction(rafting);
22032 raftclk=0;
22033 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22034 else sfx(tmpscr->secretsfx);
22035 dir = i;
22036 break;
22037 }
22038 }
22039 }
22040 }
22041 }
22042
22043 return;
22044
22045 default:
22046 577861 break;
22047 //return;
22048 }
22049
22050
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 577861 times.
✗ Branch 2 not taken.
577861 switch(flag3)
22051 {
22052 case mfDIVE_ITEM:
22053 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
22054 {
22055 additem(x, y, tmpscr->catchall,
22056 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22057 sfx(tmpscr->secretsfx);
22058 }
22059
22060 return;
22061
22062 case mfRAFT:
22063 case mfRAFT_BRANCH:
22064
22065 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22066 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22067 {
22068 bool doraft = true;
22069 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22070 {
22071 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22072 {
22073 doraft = false;
22074 }
22075 }
22076 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22077 {
22078 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22079 {
22080 reset_swordcharge();
22081 action=rafting; FFCore.setHeroAction(rafting);
22082 raftclk=0;
22083 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22084 else sfx(tmpscr->secretsfx);
22085 }
22086 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22087 {
22088 for (int32_t i = 0; i < 4; ++i)
22089 {
22090 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22091 {
22092 reset_swordcharge();
22093 action=rafting; FFCore.setHeroAction(rafting);
22094 raftclk=0;
22095 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22096 else sfx(tmpscr->secretsfx);
22097 dir = i;
22098 break;
22099 }
22100 }
22101 }
22102 }
22103 }
22104
22105 return;
22106
22107 default:
22108 577861 return;
22109 }
22110 }
22111
22112
22113 620 int32_t t=(currscr<128)?0:1;
22114
22115
3/4
✓ Branch 0 taken 503 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
620 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
22116
22117 //don't do this for canceled warps -DD
22118 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
22119 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
22120 {
22121 draw_screen(tmpscr);
22122 advanceframe(true);
22123 }*/
22124
22125 620 bool skippedaframe=false;
22126
22127
6/6
✓ Branch 0 taken 503 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 481 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 34 times.
620 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
22128 {
22129 // Stop music only if:
22130 // * entering a Guy Cave
22131 // * warping to a DMap whose music is different.
22132
22133 586 int32_t tdm = tmpscr[t].tilewarpdmap[index];
22134
22135
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 106 times.
586 if(tmpscr[t].tilewarptype[index]<=wtPASS)
22136 {
22137
3/4
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 225 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 255 times.
480 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
22138 255 music_stop();
22139 480 }
22140 else
22141 {
22142
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 96 times.
106 if(zcmusic!=NULL)
22143 {
22144
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
22145
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
22146 10 music_stop();
22147 10 }
22148
3/4
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
96 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
22149 91 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
22150 91 music_stop();
22151 }
22152
22153 586 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
22154
5/6
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 225 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 255 times.
586 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
22155 361 ? false : COOLSCROLL);
22156
22157 586 FFCore.warpScriptCheck();
22158 586 draw_screen(tmpscr);
22159 586 advanceframe(true);
22160
22161 586 skippedaframe=true;
22162
22163
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 564 times.
586 if(type==cCAVE2) walkup2(opening);
22164
2/2
✓ Branch 0 taken 447 times.
✓ Branch 1 taken 117 times.
564 else if(type==cCAVE) walkdown(opening);
22165 586 }
22166
22167
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 32 times.
620 if(type==cPIT)
22168 {
22169 32 didpit=true;
22170 32 pitx=x;
22171 32 pity=y;
22172 32 warp_sound = warpsfx2;
22173 32 }
22174
22175
5/6
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
675 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
22176
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
357 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
22177 {
22178
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!skippedaframe)
22179 {
22180 FFCore.warpScriptCheck();
22181 draw_screen(tmpscr);
22182 advanceframe(true);
22183 }
22184
22185 // "take any road you want"
22186
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
22187 55 int32_t code = WARPCODE(currdmap,homescr,dw);
22188
22189
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(code>-1)
22190 {
22191 55 bool changedlevel = false;
22192 55 bool changeddmap = false;
22193
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 if(currdmap != code>>8)
22194 {
22195 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22196 15 changeddmap = true;
22197 15 }
22198
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(dlevel != DMaps[code>>8].level)
22199 {
22200 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22201 changedlevel = true;
22202 }
22203 55 currdmap = code>>8;
22204 55 dlevel = DMaps[currdmap].level;
22205
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 if(changeddmap)
22206 {
22207 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22208 15 }
22209
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(changedlevel)
22210 {
22211 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22212 }
22213
22214 55 currmap = DMaps[currdmap].map;
22215 55 homescr = (code&0xFF) + DMaps[currdmap].xoff;
22216 55 init_dmap();
22217
22218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(canPermSecret())
22219 55 setmapflag(mSECRET);
22220 55 }
22221
22222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(specialcave==STAIRCAVE) exitcave();
22223
22224 55 return;
22225 }
22226
22227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(type==cRESET)
22228 {
22229 if(!skippedaframe)
22230 {
22231 FFCore.warpScriptCheck();
22232 draw_screen(tmpscr);
22233 advanceframe(true);
22234 }
22235
22236 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
22237
22238 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
22239
22240 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
22241
22242 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
22243
22244 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
22245
22246 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
22247
22248 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
22249
22250 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
22251
22252 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
22253
22254 if(isdungeon())
22255 {
22256 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
22257
22258 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
22259
22260 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
22261
22262 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
22263 }
22264
22265 didpit=true;
22266 pitx=x;
22267 pity=y;
22268 sdir=dir;
22269 dowarp(4,0, warpsfx2);
22270 }
22271 else
22272 {
22273
3/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
565 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
22274 {
22275 34 FFCore.warpScriptCheck();
22276 34 draw_screen(tmpscr);
22277 34 advanceframe(true);
22278 34 }
22279
22280 565 sdir = dir;
22281 565 dowarp(0,index, warpsfx2);
22282 }
22283 2438227 }
22284
22285 21 int32_t selectWlevel(int32_t d)
22286 {
22287
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(TriforceCount()==0)
22288 return 0;
22289
22290 21 word l = game->get_wlevel();
22291
22292 21 do
22293 {
22294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
22295 break;
22296
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 18 times.
50 else if(d<0)
22297
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 3 times.
18 l = (l==0) ? 7 : l-1;
22298 else
22299
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28 times.
32 l = (l==7) ? 0 : l+1;
22300
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 21 times.
50 }
22301 50 while(!(game->lvlitems[l+1] & liTRIFORCE));
22302
22303 21 game->set_wlevel(l);
22304 21 return l;
22305 21 }
22306
22307 // Would someone tell the Dodongos to shut their yaps?!
22308 3800 void kill_enemy_sfx()
22309 {
22310
2/2
✓ Branch 0 taken 3800 times.
✓ Branch 1 taken 6937 times.
10737 for(int32_t i=0; i<guys.Count(); i++)
22311 {
22312
2/2
✓ Branch 0 taken 3658 times.
✓ Branch 1 taken 3279 times.
6937 if(((enemy*)guys.spr(i))->bgsfx)
22313 3279 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
22314 6937 }
22315
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3780 times.
3800 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
22316
2/2
✓ Branch 0 taken 3797 times.
✓ Branch 1 taken 3 times.
3800 if(tmpscr->room==rGANON)
22317 3 stop_sfx(WAV_ROAR);
22318 3800 }
22319
22320 94 bool HeroClass::HasHeavyBoots()
22321 {
22322
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 24064 times.
24158 for ( int32_t q = 0; q < MAXITEMS; ++q )
22323 {
22324
5/6
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 23796 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
24064 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
22325 24064 }
22326 94 return false;
22327 94 }
22328
22329 const char *roomtype_string[rMAX] =
22330 {
22331 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
22332 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
22333 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
22334 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
22335 };
22336
22337 699 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
22338 {
22339 699 byte reposition_sword_postwarp = 0;
22340
1/2
✓ Branch 0 taken 699 times.
✗ Branch 1 not taken.
699 if(index<0)
22341 {
22342 return false;
22343 }
22344 699 is_warping = true;
22345
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 699 times.
740 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
22346 {
22347 41 weapon *swd=NULL;
22348 41 swd = (weapon*)Lwpns.spr(q);
22349
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1 times.
41 if(swd->id == (attack==wSword ? wSword : wWand))
22350 {
22351 1 Lwpns.del(q);
22352 1 }
22353 41 }
22354
22355 699 attackclk = charging = spins = tapping = 0;
22356 699 attack = none;
22357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 699 times.
699 if ( warp_sound > 0 ) warpsfx = warp_sound;
22358 699 warp_sound = 0;
22359 699 word wdmap=0;
22360 699 byte wscr=0,wtype=0,t=0;
22361 699 bool overlay=false;
22362 699 t=(currscr<128)?0:1;
22363 699 int32_t wrindex = 0;
22364 699 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
22365
22366 // Drawing commands probably shouldn't carry over...
22367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 699 times.
699 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
22368 699 script_drawing_commands.Clear();
22369
22370
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
699 switch(type)
22371 {
22372 case 0: // tile warp
22373 565 wtype = tmpscr[t].tilewarptype[index];
22374 565 wdmap = tmpscr[t].tilewarpdmap[index];
22375 565 wscr = tmpscr[t].tilewarpscr[index];
22376 565 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
22377 565 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
22378 565 break;
22379
22380 case 1: // side warp
22381 114 wtype = tmpscr[t].sidewarptype[index];
22382 114 wdmap = tmpscr[t].sidewarpdmap[index];
22383 114 wscr = tmpscr[t].sidewarpscr[index];
22384 114 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
22385 114 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
22386 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
22387 //there is no doscript for screen scripts. They run like ffcs.
22388
22389 114 break;
22390
22391 case 2: // whistle warp
22392 {
22393 20 wtype = wtWHISTLE;
22394
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
22395 20 int32_t level=0;
22396
22397
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(blowcnt==0)
22398 level = selectWlevel(0);
22399 else
22400 {
22401
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 for(int32_t i=0; i<abs(blowcnt); i++)
22402 21 level = selectWlevel(blowcnt);
22403 }
22404
22405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
22406 {
22407 level %= QMisc.warp[wind].size;
22408 game->set_wlevel(level);
22409 }
22410
22411 20 wdmap = QMisc.warp[wind].dmap[level];
22412 20 wscr = QMisc.warp[wind].scr[level];
22413 }
22414 20 break;
22415
22416 case 3:
22417 wtype = wtIWARP;
22418 wdmap = cheat_goto_dmap;
22419 wscr = cheat_goto_screen;
22420 break;
22421
22422 case 4:
22423 wtype = wtIWARP;
22424 wdmap = currdmap;
22425 wscr = homescr-DMaps[currdmap].xoff;
22426 break;
22427 }
22428
22429 699 bool intradmap = (wdmap == currdmap);
22430 699 int32_t olddmap = currdmap;
22431 699 rehydratelake(type!=wtSCROLL);
22432
22433
7/8
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 137 times.
✓ Branch 4 taken 171 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 18 times.
699 switch(wtype)
22434 {
22435 case wtCAVE:
22436 {
22437 // cave/item room
22438 288 ALLOFF();
22439 288 homescr=currscr;
22440 288 currscr=0x80;
22441
22442
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 88 times.
288 if(DMaps[currdmap].flags&dmfCAVES) // cave
22443 {
22444 200 music_stop();
22445 200 kill_sfx();
22446
22447
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 140 times.
200 if(tmpscr->room==rWARP)
22448 {
22449 60 currscr=0x81;
22450 60 specialcave = STAIRCAVE;
22451 60 }
22452 140 else specialcave = GUYCAVE;
22453
22454 //lighting(2,dir);
22455 200 lighting(false, true);
22456 200 loadlvlpal(10);
22457
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 38 times.
362 bool b2 = COOLSCROLL&&
22458
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
162 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
22459
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
120 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
22460
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
120 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
22461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
22462 200 blackscr(30,b2?false:true);
22463 200 loadscr(0,wdmap,currscr,up,false);
22464 200 loadscr(1,wdmap,homescr,up,false);
22465 //preloaded freeform combos
22466 200 ffscript_engine(true);
22467 200 putscr(scrollbuf,0,0,tmpscr);
22468 200 putscrdoors(scrollbuf,0,0,tmpscr);
22469 200 dir=up;
22470 200 x=112;
22471 200 y=160;
22472
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(didpit)
22473 {
22474 didpit=false;
22475 x=pitx;
22476 y=pity;
22477 }
22478
22479 200 reset_hookshot();
22480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(reposition_sword_postwarp)
22481 {
22482 weapon *swd=NULL;
22483 for(int32_t i=0; i<Lwpns.Count(); i++)
22484 {
22485 swd = (weapon*)Lwpns.spr(i);
22486
22487 if(swd->id == (attack==wSword ? wSword : wWand))
22488 {
22489 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22490 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22491 positionSword(swd,item_id);
22492 break;
22493 }
22494 }
22495 }
22496 200 stepforward(diagonalMovement?5:6, false);
22497 200 }
22498 else // item room
22499 {
22500 88 specialcave = ITEMCELLAR;
22501 88 map_bkgsfx(false);
22502 88 kill_enemy_sfx();
22503 88 draw_screen(tmpscr,false);
22504
22505 //unless the room is already dark, fade to black
22506
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 87 times.
88 if(!darkroom)
22507 {
22508 87 darkroom = true;
22509 87 fade(DMaps[currdmap].color,true,false);
22510 87 }
22511
22512 88 blackscr(30,true);
22513 88 loadscr(0,wdmap,currscr,down,false);
22514 88 loadscr(1,wdmap,homescr,-1,false);
22515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if ( dontdraw < 2 ) { dontdraw=1; }
22516 88 draw_screen(tmpscr);
22517 88 fade(11,true,true);
22518 88 darkroom = false;
22519 88 dir=down;
22520 88 x=48;
22521 88 y=0;
22522
22523 // is this didpit check necessary?
22524
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(didpit)
22525 {
22526 didpit=false;
22527 x=pitx;
22528 y=pity;
22529 }
22530
22531 88 reset_hookshot();
22532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(reposition_sword_postwarp)
22533 {
22534 weapon *swd=NULL;
22535 for(int32_t i=0; i<Lwpns.Count(); i++)
22536 {
22537 swd = (weapon*)Lwpns.spr(i);
22538
22539 if(swd->id == (attack==wSword ? wSword : wWand))
22540 {
22541 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22542 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22543 positionSword(swd,item_id);
22544 break;
22545 }
22546 }
22547 }
22548 88 lighting(false, true);
22549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if ( dontdraw < 2 ) { dontdraw=0; }
22550 88 stepforward(diagonalMovement?16:18, false);
22551 }
22552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
22553 288 break;
22554 }
22555
22556 case wtPASS: // passageway
22557 {
22558 137 map_bkgsfx(false);
22559 137 kill_enemy_sfx();
22560 137 ALLOFF();
22561 //play sound
22562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22563 137 homescr=currscr;
22564 137 currscr=0x81;
22565 137 specialcave = PASSAGEWAY;
22566 137 byte warpscr2 = wscr + DMaps[wdmap].xoff;
22567 137 draw_screen(tmpscr,false);
22568
22569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
22570 {
22571
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 129 times.
137 if(!darkroom)
22572 129 fade(DMaps[currdmap].color,true,false);
22573
22574 137 darkroom=true;
22575 137 }
22576 137 blackscr(30,true);
22577 137 loadscr(0,wdmap,currscr,down,false);
22578 137 loadscr(1,wdmap,homescr,-1,false);
22579 //preloaded freeform combos
22580 137 ffscript_engine(true);
22581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 if ( dontdraw < 2 ) { dontdraw=1; }
22582 137 draw_screen(tmpscr);
22583 137 lighting(false, true);
22584 137 dir=down;
22585 137 x=48;
22586
22587
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 69 times.
137 if((homescr&15) > (warpscr2&15))
22588 {
22589 69 x=192;
22590 69 }
22591
22592
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if((homescr&15) == (warpscr2&15))
22593 {
22594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if((currscr>>4) > (warpscr2>>4))
22595 {
22596 1 x=192;
22597 1 }
22598 1 }
22599
22600 // is this didpit check necessary?
22601
1/2
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
137 if(didpit)
22602 {
22603 didpit=false;
22604 x=pitx;
22605 y=pity;
22606 }
22607
22608 137 y=0;
22609 137 set_respawn_point();
22610 137 trySideviewLadder();
22611 137 reset_hookshot();
22612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 if(reposition_sword_postwarp)
22613 {
22614 weapon *swd=NULL;
22615 for(int32_t i=0; i<Lwpns.Count(); i++)
22616 {
22617 swd = (weapon*)Lwpns.spr(i);
22618
22619 if(swd->id == (attack==wSword ? wSword : wWand))
22620 {
22621 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22622 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22623 positionSword(swd,item_id);
22624 break;
22625 }
22626 }
22627 }
22628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 if ( dontdraw < 2 ) { dontdraw=0; }
22629 137 stepforward(diagonalMovement?16:18, false);
22630 137 newscr_clk=frame;
22631 137 activated_timed_warp=false;
22632 137 stepoutindex=index;
22633 137 stepoutscr = warpscr2;
22634 137 stepoutdmap = wdmap;
22635 137 stepoutwr=wrindex;
22636 }
22637 137 break;
22638
22639 case wtEXIT: // entrance/exit
22640 {
22641 171 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
22642 171 ALLOFF();
22643 171 music_stop();
22644 171 kill_sfx();
22645 171 blackscr(30,false);
22646 171 bool changedlevel = false;
22647 171 bool changeddmap = false;
22648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(currdmap != wdmap)
22649 {
22650 171 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22651 171 changeddmap = true;
22652 171 }
22653
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 170 times.
171 if(dlevel != DMaps[wdmap].level)
22654 {
22655 170 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22656 170 changedlevel = true;
22657 170 }
22658 171 dlevel = DMaps[wdmap].level;
22659 171 currdmap = wdmap;
22660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(changeddmap)
22661 {
22662 171 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22663 171 }
22664
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 170 times.
171 if(changedlevel)
22665 {
22666 170 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22667 170 }
22668
22669 171 currmap=DMaps[currdmap].map;
22670 171 init_dmap();
22671 171 update_subscreens(wdmap);
22672 171 loadfullpal();
22673 171 ringcolor(false);
22674 171 loadlvlpal(DMaps[currdmap].color);
22675 //lastentrance_dmap = currdmap;
22676 171 homescr = currscr = wscr + DMaps[currdmap].xoff;
22677 171 loadscr(0,currdmap,currscr,-1,overlay);
22678
22679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
171 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
22680 {
22681 if(get_bit(quest_rules,qr_FADE))
22682 {
22683 interpolatedfade();
22684 }
22685 else
22686 {
22687 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
22688 }
22689
22690 darkroom=naturaldark=true;
22691 }
22692 else
22693 {
22694 171 darkroom=naturaldark=false;
22695 }
22696
22697 int32_t wrx,wry;
22698
22699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22700 {
22701 wrx=tmpscr->warpreturnx[0];
22702 wry=tmpscr->warpreturny[0];
22703 }
22704 else
22705 {
22706 171 wrx=tmpscr->warparrivalx;
22707 171 wry=tmpscr->warparrivaly;
22708 }
22709
22710
6/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 145 times.
171 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22711 {
22712
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 50 times.
145 if(dlevel)
22713 {
22714 95 lastentrance = currscr;
22715 95 }
22716 else
22717 {
22718 50 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22719 }
22720
22721 145 lastentrance_dmap = wdmap;
22722 145 }
22723
22724
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 76 times.
171 if(dlevel)
22725 {
22726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22727 {
22728 x=tmpscr->warpreturnx[wrindex];
22729 y=tmpscr->warpreturny[wrindex];
22730 }
22731 else
22732 {
22733 95 x=tmpscr->warparrivalx;
22734 95 y=tmpscr->warparrivaly;
22735 }
22736 95 }
22737 else
22738 {
22739 76 x=tmpscr->warpreturnx[wrindex];
22740 76 y=tmpscr->warpreturny[wrindex];
22741 }
22742
22743
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(didpit)
22744 {
22745 didpit=false;
22746 x=pitx;
22747 y=pity;
22748 }
22749
22750 171 dir=down;
22751
22752
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 159 times.
171 if(x==0) dir=right;
22753
22754
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 163 times.
171 if(x==240) dir=left;
22755
22756
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 165 times.
171 if(y==0) dir=down;
22757
22758
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 102 times.
171 if(y==160) dir=up;
22759
22760
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 76 times.
171 if(dlevel)
22761 {
22762 // reset enemy kill counts
22763
2/2
✓ Branch 0 taken 12160 times.
✓ Branch 1 taken 95 times.
12255 for(int32_t i=0; i<128; i++)
22764 {
22765 12160 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
22766 12160 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
22767 12160 }
22768 95 }
22769
22770 171 markBmap(dir^1);
22771 //preloaded freeform combos
22772 171 ffscript_engine(true);
22773
22774 171 reset_hookshot();
22775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(reposition_sword_postwarp)
22776 {
22777 weapon *swd=NULL;
22778 for(int32_t i=0; i<Lwpns.Count(); i++)
22779 {
22780 swd = (weapon*)Lwpns.spr(i);
22781
22782 if(swd->id == (attack==wSword ? wSword : wWand))
22783 {
22784 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22785 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22786 positionSword(swd,item_id);
22787 break;
22788 }
22789 }
22790 }
22791
22792
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 83 times.
171 if(isdungeon())
22793 {
22794 88 openscreen();
22795
2/4
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
88 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
22796 88 stepforward(diagonalMovement?11:12, false);
22797 else
22798 // Didn't walk as far pre-1.93, and some quests depend on that
22799 stepforward(8, false);
22800 88 }
22801 else
22802 {
22803
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 60 times.
83 if(!COOLSCROLL)
22804 23 openscreen();
22805
22806 83 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
22807 83 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22808 83 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
22809
22810
5/10
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 36 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
83 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
22811 {
22812 47 reset_pal_cycling();
22813 47 putscr(scrollbuf,0,0,tmpscr);
22814 47 putscrdoors(scrollbuf,0,0,tmpscr);
22815 47 walkup(COOLSCROLL);
22816 47 }
22817
5/10
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 33 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
36 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
22818 {
22819 3 reset_pal_cycling();
22820 3 putscr(scrollbuf,0,0,tmpscr);
22821 3 putscrdoors(scrollbuf,0,0,tmpscr);
22822 3 walkdown2(COOLSCROLL);
22823 3 }
22824
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13 times.
33 else if(COOLSCROLL)
22825 {
22826 20 openscreen();
22827 20 }
22828 }
22829
22830 171 show_subscreen_life=true;
22831 171 show_subscreen_numbers=true;
22832 171 playLevelMusic();
22833 171 currcset=DMaps[currdmap].color;
22834 171 dointro();
22835 171 set_respawn_point();
22836 171 trySideviewLadder();
22837
22838
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 171 times.
1197 for(int32_t i=0; i<6; i++)
22839 1026 visited[i]=-1;
22840
22841 171 break;
22842 }
22843
22844 case wtSCROLL: // scrolling warp
22845 {
22846 18 int32_t c = DMaps[currdmap].color;
22847 18 scrolling_map = currmap;
22848 18 currmap = DMaps[wdmap].map;
22849 18 update_subscreens(wdmap);
22850
22851 18 dlevel = DMaps[wdmap].level;
22852 //check if Hero has the map for the new location before updating the subscreen. ? -Z
22853 //This works only in one direction, if Hero had a map, to not having one.
22854 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
22855 18 update_subscreens(wdmap);
22856
22857 /*if ( has_item(itype_map, dlevel) )
22858 {
22859 //Blank the map during an intra-dmap scrolling warp.
22860 dlevel = -1; //a hack for the minimap. This works!! -Z
22861 }*/
22862
22863 // fix the scrolling direction, if it was a tile or instant warp
22864
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(type==0 || type>=3)
22865 {
22866 sdir = dir;
22867 }
22868
22869 18 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
22870 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
22871
22872 18 reset_hookshot();
22873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(reposition_sword_postwarp)
22874 {
22875 weapon *swd=NULL;
22876 for(int32_t i=0; i<Lwpns.Count(); i++)
22877 {
22878 swd = (weapon*)Lwpns.spr(i);
22879
22880 if(swd->id == (attack==wSword ? wSword : wWand))
22881 {
22882 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22883 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22884 positionSword(swd,item_id);
22885 break;
22886 }
22887 }
22888 }
22889
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 14 times.
18 if(!intradmap)
22890 {
22891 14 homescr = currscr = wscr + DMaps[wdmap].xoff;
22892 14 init_dmap();
22893
22894 int32_t wrx,wry;
22895
22896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22897 {
22898 wrx=tmpscr->warpreturnx[0];
22899 wry=tmpscr->warpreturny[0];
22900 }
22901 else
22902 {
22903 14 wrx=tmpscr->warparrivalx;
22904 14 wry=tmpscr->warparrivaly;
22905 }
22906
22907
4/8
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22908 {
22909 if(dlevel)
22910 {
22911 lastentrance = currscr;
22912 }
22913 else
22914 {
22915 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22916 }
22917
22918 lastentrance_dmap = wdmap;
22919 }
22920 14 }
22921
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(DMaps[currdmap].color != c)
22922 {
22923 lighting(false, true);
22924 }
22925
22926 18 playLevelMusic();
22927 18 currcset=DMaps[currdmap].color;
22928 18 dointro();
22929 }
22930 18 break;
22931
22932 case wtWHISTLE: // whistle warp
22933 {
22934 20 scrolling_map = currmap;
22935 20 currmap = DMaps[wdmap].map;
22936 20 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
22937 20 reset_hookshot();
22938 20 currdmap=wdmap;
22939 20 dlevel=DMaps[currdmap].level;
22940 20 lighting(false, true);
22941 20 init_dmap();
22942
22943 20 playLevelMusic();
22944 20 currcset=DMaps[currdmap].color;
22945 20 dointro();
22946 20 action=inwind; FFCore.setHeroAction(inwind);
22947 int32_t wry;
22948
22949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22950 wry=tmpscr->warpreturny[0];
22951 20 else wry=tmpscr->warparrivaly;
22952
22953 int32_t wrx;
22954
22955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22956 wrx=tmpscr->warpreturnx[0];
22957 20 else wrx=tmpscr->warparrivalx;
22958
22959
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
40 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
22960
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
22961 20 whirlwind=255;
22962 20 whistleitem=-1;
22963 }
22964 20 break;
22965
22966 case wtIWARP:
22967 case wtIWARPBLK:
22968 case wtIWARPOPEN:
22969 case wtIWARPZAP:
22970 case wtIWARPWAVE: // insta-warps
22971 {
22972 47 bool old_192 = false;
22973
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if (get_bit(quest_rules,qr_192b163_WARP))
22974 {
22975 if ( wtype == wtIWARPWAVE )
22976 {
22977 wtype = wtIWARPWAVE;
22978 old_192 = true;
22979 }
22980 if ( old_192 )
22981 {
22982 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
22983 didpit=false;
22984 update_subscreens();
22985 warp_sound = 0;
22986 is_warping = false;
22987 return false;
22988 }
22989 }
22990 //for determining whether to exit cave
22991 47 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
22992 47 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22993 47 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
22994
22995
5/8
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 45 times.
92 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
22996
4/8
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
✓ Branch 6 taken 45 times.
✗ Branch 7 not taken.
45 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
22997
22998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
22999 {
23000 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23001 47 bool wasswimming = (action == swimming);
23002 47 int32_t olddiveclk = diveclk;
23003 47 ALLOFF();
23004
23005
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2 times.
47 if(wasswimming)
23006 {
23007 2 Hero.SetSwim();
23008 2 diveclk = olddiveclk;
23009 2 }
23010
23011 47 kill_sfx();
23012 47 }
23013 //play sound
23014
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23015
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 39 times.
47 if(wtype==wtIWARPZAP)
23016 {
23017 8 zapout();
23018 8 }
23019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 else if(wtype==wtIWARPWAVE)
23020 {
23021 //only draw Hero if he's not in a cave -DD
23022 wavyout(!cavewarp);
23023 }
23024
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 6 times.
39 else if(wtype!=wtIWARP)
23025 {
23026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 bool b2 = COOLSCROLL&&cavewarp;
23027 6 blackscr(30,b2?false:true);
23028 6 }
23029
23030 47 int32_t c = DMaps[currdmap].color;
23031 47 bool changedlevel = false;
23032 47 bool changeddmap = false;
23033
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 41 times.
47 if(currdmap != wdmap)
23034 {
23035 41 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23036 41 changeddmap = true;
23037 41 }
23038
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 6 times.
47 if(dlevel != DMaps[wdmap].level)
23039 {
23040 6 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23041 6 changedlevel = true;
23042 6 }
23043 47 dlevel = DMaps[wdmap].level;
23044 47 currdmap = wdmap;
23045
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 41 times.
47 if(changeddmap)
23046 {
23047 41 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23048 41 }
23049
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 6 times.
47 if(changedlevel)
23050 {
23051 6 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23052 6 }
23053
23054 47 currmap = DMaps[currdmap].map;
23055 47 init_dmap();
23056 47 update_subscreens(wdmap);
23057
23058 47 ringcolor(false);
23059
23060
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 4 times.
47 if(DMaps[currdmap].color != c)
23061 4 loadlvlpal(DMaps[currdmap].color);
23062
23063 47 homescr = currscr = wscr + DMaps[currdmap].xoff;
23064
23065 47 lightingInstant(); // Also sets naturaldark
23066
23067 47 loadscr(0,currdmap,currscr,-1,overlay);
23068
23069 47 x = tmpscr->warpreturnx[wrindex];
23070 47 y = tmpscr->warpreturny[wrindex];
23071
23072
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 32 times.
47 if(didpit)
23073 {
23074 32 didpit=false;
23075 32 x=pitx;
23076 32 y=pity;
23077 32 }
23078
23079 47 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23080 47 type2 = combobuf[MAPCOMBO(x,y)].type;
23081 47 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23082
23083
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1 times.
47 if(x==0) dir=right;
23084
23085
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(x==240) dir=left;
23086
23087
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(y==0) dir=down;
23088
23089
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1 times.
47 if(y==160) dir=up;
23090
23091 47 markBmap(dir^1);
23092
23093 47 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
23094
23095
10/16
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 45 times.
49 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23096 {
23097 2 hopclk=0xFF;
23098 2 SetSwim();
23099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!IsSideSwim()) attackclk = charging = spins = 0;
23100 2 }
23101 else
23102 {
23103 45 action = none; FFCore.setHeroAction(none);
23104 }
23105 //preloaded freeform combos
23106 47 ffscript_engine(true);
23107
23108 47 putscr(scrollbuf,0,0,tmpscr);
23109 47 putscrdoors(scrollbuf,0,0,tmpscr);
23110
23111
5/10
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 45 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
47 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23112 {
23113 2 reset_pal_cycling();
23114 2 putscr(scrollbuf,0,0,tmpscr);
23115 2 putscrdoors(scrollbuf,0,0,tmpscr);
23116 2 walkup(COOLSCROLL);
23117 2 }
23118
4/10
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 45 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
45 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23119 {
23120 reset_pal_cycling();
23121 putscr(scrollbuf,0,0,tmpscr);
23122 putscrdoors(scrollbuf,0,0,tmpscr);
23123 walkdown2(COOLSCROLL);
23124 }
23125
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 37 times.
45 else if(wtype==wtIWARPZAP)
23126 {
23127 8 zapin();
23128 8 }
23129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 else if(wtype==wtIWARPWAVE)
23130 {
23131 wavyin();
23132 }
23133
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2 times.
37 else if(wtype==wtIWARPOPEN)
23134 {
23135 2 openscreen();
23136 2 }
23137
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(reposition_sword_postwarp)
23138 {
23139 weapon *swd=NULL;
23140 for(int32_t i=0; i<Lwpns.Count(); i++)
23141 {
23142 swd = (weapon*)Lwpns.spr(i);
23143
23144 if(swd->id == (attack==wSword ? wSword : wWand))
23145 {
23146 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23147 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23148 positionSword(swd,item_id);
23149 break;
23150 }
23151 }
23152 }
23153 47 show_subscreen_life=true;
23154 47 show_subscreen_numbers=true;
23155 47 playLevelMusic();
23156 47 currcset=DMaps[currdmap].color;
23157 47 dointro();
23158 47 set_respawn_point();
23159 47 trySideviewLadder();
23160 }
23161 47 break;
23162
23163
23164 case wtNOWARP:
23165 {
23166 18 bool old_192 = false;
23167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (get_bit(quest_rules,qr_192b163_WARP))
23168 {
23169 wtype = wtIWARPWAVE;
23170 old_192 = true;
23171 }
23172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( old_192 )
23173 {
23174 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
23175 //for determining whether to exit cave
23176 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23177 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23178 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23179
23180 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
23181 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
23182
23183 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
23184 {
23185 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23186 bool wasswimming = (action == swimming);
23187 int32_t olddiveclk = diveclk;
23188 ALLOFF();
23189
23190 if(wasswimming)
23191 {
23192 Hero.SetSwim();
23193 diveclk = olddiveclk;
23194 }
23195
23196 kill_sfx();
23197 }
23198 //play sound
23199 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23200 if(wtype==wtIWARPZAP)
23201 {
23202 zapout();
23203 }
23204 else if(wtype==wtIWARPWAVE)
23205 {
23206 //only draw Hero if he's not in a cave -DD
23207 wavyout(!cavewarp);
23208 }
23209 else if(wtype!=wtIWARP)
23210 {
23211 bool b2 = COOLSCROLL&&cavewarp;
23212 blackscr(30,b2?false:true);
23213 }
23214
23215 int32_t c = DMaps[currdmap].color;
23216 bool changedlevel = false;
23217 bool changeddmap = false;
23218 if(currdmap != wdmap)
23219 {
23220 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23221 changeddmap = true;
23222 }
23223 if(dlevel != DMaps[wdmap].level)
23224 {
23225 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23226 changedlevel = true;
23227 }
23228 dlevel = DMaps[wdmap].level;
23229 currdmap = wdmap;
23230 if(changeddmap)
23231 {
23232 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23233 }
23234 if(changedlevel)
23235 {
23236 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23237 }
23238 currmap = DMaps[currdmap].map;
23239 init_dmap();
23240 update_subscreens(wdmap);
23241
23242 ringcolor(false);
23243
23244 if(DMaps[currdmap].color != c)
23245 loadlvlpal(DMaps[currdmap].color);
23246
23247 homescr = currscr = wscr + DMaps[currdmap].xoff;
23248
23249 lightingInstant(); // Also sets naturaldark
23250
23251 loadscr(0,currdmap,currscr,-1,overlay);
23252
23253 x = tmpscr->warpreturnx[wrindex];
23254 y = tmpscr->warpreturny[wrindex];
23255
23256 if(didpit)
23257 {
23258 didpit=false;
23259 x=pitx;
23260 y=pity;
23261 }
23262
23263 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23264 type2 = combobuf[MAPCOMBO(x,y)].type;
23265 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23266
23267 if(x==0) dir=right;
23268
23269 if(x==240) dir=left;
23270
23271 if(y==0) dir=down;
23272
23273 if(y==160) dir=up;
23274
23275 markBmap(dir^1);
23276
23277 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
23278 {
23279 hopclk=0xFF;
23280 SetSwim();
23281 if (!IsSideSwim()) attackclk = charging = spins = 0;
23282 }
23283 else
23284 {
23285 action = none;
23286 FFCore.setHeroAction(none);
23287 }
23288 //preloaded freeform combos
23289 ffscript_engine(true);
23290
23291 putscr(scrollbuf,0,0,tmpscr);
23292 putscrdoors(scrollbuf,0,0,tmpscr);
23293
23294 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23295 {
23296 reset_pal_cycling();
23297 putscr(scrollbuf,0,0,tmpscr);
23298 putscrdoors(scrollbuf,0,0,tmpscr);
23299 walkup(COOLSCROLL);
23300 }
23301 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23302 {
23303 reset_pal_cycling();
23304 putscr(scrollbuf,0,0,tmpscr);
23305 putscrdoors(scrollbuf,0,0,tmpscr);
23306 walkdown2(COOLSCROLL);
23307 }
23308 else if(wtype==wtIWARPZAP)
23309 {
23310 zapin();
23311 }
23312 else if(wtype==wtIWARPWAVE)
23313 {
23314 wavyin();
23315 }
23316 else if(wtype==wtIWARPOPEN)
23317 {
23318 openscreen();
23319 }
23320 if(reposition_sword_postwarp)
23321 {
23322 weapon *swd=NULL;
23323 for(int32_t i=0; i<Lwpns.Count(); i++)
23324 {
23325 swd = (weapon*)Lwpns.spr(i);
23326
23327 if(swd->id == (attack==wSword ? wSword : wWand))
23328 {
23329 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23330 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23331 positionSword(swd,item_id);
23332 break;
23333 }
23334 }
23335 }
23336 show_subscreen_life=true;
23337 show_subscreen_numbers=true;
23338 playLevelMusic();
23339 currcset=DMaps[currdmap].color;
23340 dointro();
23341 set_respawn_point();
23342 trySideviewLadder();
23343 break;
23344 }
23345 else
23346 {
23347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(reposition_sword_postwarp)
23348 {
23349 weapon *swd=NULL;
23350 for(int32_t i=0; i<Lwpns.Count(); i++)
23351 {
23352 swd = (weapon*)Lwpns.spr(i);
23353
23354 if(swd->id == (attack==wSword ? wSword : wWand))
23355 {
23356 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23357 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23358 positionSword(swd,item_id);
23359 break;
23360 }
23361 }
23362 }
23363 18 didpit=false;
23364 18 update_subscreens();
23365 18 warp_sound = 0;
23366 18 is_warping = false;
23367 18 return false;
23368 }
23369 }
23370 default:
23371 didpit=false;
23372 update_subscreens();
23373 warp_sound = 0;
23374 is_warping = false;
23375 if(reposition_sword_postwarp)
23376 {
23377 weapon *swd=NULL;
23378 for(int32_t i=0; i<Lwpns.Count(); i++)
23379 {
23380 swd = (weapon*)Lwpns.spr(i);
23381
23382 if(swd->id == (attack==wSword ? wSword : wWand))
23383 {
23384 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23385 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23386 positionSword(swd,item_id);
23387 break;
23388 }
23389 }
23390 }
23391 return false;
23392 }
23393
23394
23395
23396 // Stop Hero from drowning!
23397
3/6
✓ Branch 0 taken 681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 681 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 681 times.
681 if(action==drowning || action==lavadrowning || action==sidedrowning)
23398 {
23399 drownclk=0;
23400 drownclk=0;
23401 action=none; FFCore.setHeroAction(none);
23402 }
23403
23404 681 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
23405 // But keep him swimming if he ought to be!
23406 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
23407
9/12
✓ Branch 0 taken 678 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 666 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 678 times.
✓ Branch 11 taken 3 times.
693 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
23408 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
23409
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
12 && (action!=inwind))
23410 {
23411 3 hopclk=0xFF;
23412 3 SetSwim();
23413 3 }
23414
23415 681 newscr_clk=frame;
23416 681 activated_timed_warp=false;
23417 681 eat_buttons();
23418
23419
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 648 times.
681 if(wtype!=wtIWARP)
23420 648 attackclk=0;
23421
23422 681 didstuff=0;
23423 681 usecounts.clear();
23424 681 map_bkgsfx(true);
23425 681 loadside=dir^1;
23426 681 whistleclk=-1;
23427
23428
2/4
✓ Branch 0 taken 681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 681 times.
✗ Branch 3 not taken.
681 if((z>0 || fakez>0) && isSideViewHero())
23429 {
23430 y-=z;
23431 y-=fakez;
23432 fakez=0;
23433 z=0;
23434 }
23435
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 680 times.
681 else if(!isSideViewHero())
23436 {
23437 680 fall=0;
23438 680 fakefall=0;
23439 680 }
23440
23441 // If warping between top-down and sideview screens,
23442 // fix enemies that are carried over by Full Screen Warp
23443 681 const bool tmpscr_is_sideview = isSideViewHero();
23444
23445
4/4
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 679 times.
✓ Branch 3 taken 1 times.
681 if(!wasSideview && tmpscr_is_sideview)
23446 {
23447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<guys.Count(); i++)
23448 {
23449 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
23450 {
23451 guys.spr(i)->y -= guys.spr(i)->z;
23452 guys.spr(i)->y -= guys.spr(i)->fakez;
23453 guys.spr(i)->z = 0;
23454 guys.spr(i)->fakez = 0;
23455 }
23456
23457 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23458 guys.spr(i)->yofs += 2;
23459 }
23460 1 }
23461
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 679 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
680 else if(wasSideview && !tmpscr_is_sideview)
23462 {
23463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<guys.Count(); i++)
23464 {
23465 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23466 guys.spr(i)->yofs -= 2;
23467 }
23468 1 }
23469
23470
6/6
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 134 times.
✓ Branch 3 taken 291 times.
✓ Branch 4 taken 133 times.
✓ Branch 5 taken 1 times.
681 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
23471 {
23472
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 296 times.
389 if(dlevel)
23473 {
23474 int32_t wrx,wry;
23475
23476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23477 {
23478 wrx=tmpscr->warpreturnx[0];
23479 wry=tmpscr->warpreturny[0];
23480 }
23481 else
23482 {
23483 93 wrx=tmpscr->warparrivalx;
23484 93 wry=tmpscr->warparrivaly;
23485 }
23486
23487
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
93 if((wtype == wtEXIT)
23488
5/10
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 61 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
93 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
23489 {
23490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
23491 {
23492 28 game->set_continue_scrn(homescr);
23493 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
23494 28 }
23495 else if(currdmap != game->get_continue_dmap())
23496 {
23497 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23498 }
23499 28 }
23500 else
23501 {
23502
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 if(currdmap != game->get_continue_dmap())
23503 {
23504 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23505 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
23506 }
23507 }
23508 93 }
23509 else
23510 {
23511 296 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23512 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
23513 }
23514
23515 389 game->set_continue_dmap(currdmap);
23516 389 lastentrance_dmap = currdmap;
23517 389 lastentrance = game->get_continue_scrn();
23518 //Z_message("continue_map = %d\n",game->get_continue_dmap());
23519 389 }
23520
23521
1/2
✓ Branch 0 taken 681 times.
✗ Branch 1 not taken.
681 if(tmpscr->flags4&fAUTOSAVE)
23522 {
23523 save_game(true,0);
23524 }
23525
23526
1/2
✓ Branch 0 taken 681 times.
✗ Branch 1 not taken.
681 if(tmpscr->flags6&fCONTINUEHERE)
23527 {
23528 lastentrance_dmap = currdmap;
23529 lastentrance = homescr;
23530 }
23531
23532 681 update_subscreens();
23533 681 verifyBothWeapons();
23534
23535
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 288 times.
681 if(wtype==wtCAVE)
23536 {
23537
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 88 times.
288 if(DMaps[currdmap].flags&dmfGUYCAVES)
23538 400 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
23539 200 (char *)moduledata.roomtype_names[tmpscr[1].room]);
23540 else
23541 88 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
23542 288 }
23543 786 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
23544
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 256 times.
649 wtype==wtPASS ? "Passageway" :
23545
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 85 times.
341 wtype==wtEXIT ? "Entrance/Exit" :
23546
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 67 times.
85 wtype==wtSCROLL ? "Scrolling Warp" :
23547 67 wtype==wtWHISTLE ? "Whistle Warp" :
23548 "Insta-Warp");
23549
23550 681 eventlog_mapflags();
23551
1/2
✓ Branch 0 taken 681 times.
✗ Branch 1 not taken.
681 if(reposition_sword_postwarp)
23552 {
23553 weapon *swd=NULL;
23554 for(int32_t i=0; i<Lwpns.Count(); i++)
23555 {
23556 swd = (weapon*)Lwpns.spr(i);
23557
23558 if(swd->id == (attack==wSword ? wSword : wWand))
23559 {
23560 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23561 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23562 positionSword(swd,item_id);
23563 break;
23564 }
23565 }
23566 }
23567 681 FFCore.init_combo_doscript();
23568
3/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
681 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
23569 {
23570 681 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
23571 681 FFCore.initZScriptDMapScripts();
23572 681 FFCore.initZScriptActiveSubscreenScript();
23573 681 }
23574 681 is_warping = false;
23575 681 return true;
23576 699 }
23577
23578 152 void HeroClass::exitcave()
23579 {
23580 152 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23581 152 currscr=homescr;
23582 152 loadscr(0,currdmap,currscr,255,false); // bogus direction
23583 152 x = tmpscr->warpreturnx[0];
23584 152 y = tmpscr->warpreturny[0];
23585
23586
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(didpit)
23587 {
23588 didpit=false;
23589 x=pitx;
23590 y=pity;
23591 }
23592
23593
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 5 times.
152 if(x+y == 0)
23594 5 x = y = 80;
23595
23596 152 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23597 152 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23598 152 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23599
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 133 times.
303 bool b = COOLSCROLL &&
23600
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 109 times.
133 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
23601
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 108 times.
109 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
23602
4/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 90 times.
108 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
23603
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 95 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 5 times.
90 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
23604 170 ALLOFF();
23605 170 blackscr(30,b?false:true);
23606 170 ringcolor(false);
23607 170 loadlvlpal(DMaps[currdmap].color);
23608 170 lighting(false, true);
23609 170 music_stop();
23610 170 kill_sfx();
23611 170 putscr(scrollbuf,0,0,tmpscr);
23612 170 putscrdoors(scrollbuf,0,0,tmpscr);
23613
23614
9/10
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 124 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 123 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
170 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23615 {
23616 50 walkup(COOLSCROLL);
23617 50 }
23618
9/10
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 105 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
128 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23619 {
23620 18 walkdown2(COOLSCROLL);
23621 18 }
23622
23623 178 show_subscreen_life=true;
23624 178 show_subscreen_numbers=true;
23625 178 playLevelMusic();
23626 178 currcset=DMaps[currdmap].color;
23627 178 dointro();
23628 178 newscr_clk=frame;
23629 178 activated_timed_warp=false;
23630 178 dir=down;
23631 178 set_respawn_point();
23632 178 eat_buttons();
23633 178 didstuff=0;
23634 178 usecounts.clear();
23635 178 map_bkgsfx(true);
23636 178 loadside=dir^1;
23637 178 }
23638
23639
23640 2590 void HeroClass::stepforward(int32_t steps, bool adjust)
23641 {
23642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2590 times.
2590 if ( FFCore.nostepforward ) return;
23643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2590 times.
2590 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
23644 2590 zfix tx=x; //temp x
23645 2590 zfix ty=y; //temp y
23646 2590 zfix tstep(0); //temp single step distance
23647 2590 zfix s(0); //calculated step distance for all steps
23648 2590 z3step=2;
23649 2590 int32_t sh=shiftdir;
23650 2590 shiftdir=-1;
23651
23652
2/2
✓ Branch 0 taken 44224 times.
✓ Branch 1 taken 2590 times.
46814 for(int32_t i=steps; i>0; --i)
23653 {
23654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44224 times.
44224 if(diagonalMovement)
23655 {
23656 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23657 {
23658 tstep = 1.5;
23659 }
23660 else
23661 {
23662 tstep=z3step;
23663 z3step=(z3step%2)+1;
23664 }
23665 }
23666 else
23667 {
23668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44224 times.
44224 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
23669 {
23670 tstep = 1.5;
23671 }
23672 else
23673 {
23674
2/2
✓ Branch 0 taken 25755 times.
✓ Branch 1 taken 18469 times.
44224 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
23675
23676
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14391 times.
✓ Branch 2 taken 11364 times.
✓ Branch 3 taken 8032 times.
✓ Branch 4 taken 10437 times.
44224 switch(dir)
23677 {
23678 case up:
23679 14391 ty-=tstep;
23680 14391 break;
23681
23682 case down:
23683 11364 ty+=tstep;
23684 11364 break;
23685
23686 case left:
23687 8032 tx-=tstep;
23688 8032 break;
23689
23690 case right:
23691 10437 tx+=tstep;
23692 10437 break;
23693 }
23694 }
23695 }
23696
23697 44224 s+=tstep;
23698 44224 }
23699
23700 2590 z3step=2;
23701
23702 2590 x = x.getInt();
23703 2590 y = y.getInt();
23704
2/2
✓ Branch 0 taken 46771 times.
✓ Branch 1 taken 2590 times.
49361 while(s>=0)
23705 {
23706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46771 times.
46771 if(diagonalMovement)
23707 {
23708 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23709 {
23710 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23711 {
23712 walkable = false;
23713 shiftdir = -1;
23714 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23715 switch(tdir)
23716 {
23717 case left:
23718 --x;
23719 break;
23720 case right:
23721 ++x;
23722 break;
23723 case up:
23724 --y;
23725 break;
23726 case down:
23727 ++y;
23728 break;
23729 }
23730 }
23731 else
23732 {
23733 walkable=false;
23734 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23735 move(dir, 150);
23736 }
23737 }
23738 else
23739 {
23740 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23741 {
23742 s-=1.5;
23743 }
23744 else
23745 {
23746 s-=z3step;
23747 }
23748 walkable=true;
23749 move(dir, 150);
23750 }
23751
23752 shiftdir=-1;
23753 }
23754 else
23755 {
23756
3/6
✓ Branch 0 taken 27297 times.
✓ Branch 1 taken 19474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46771 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
46771 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23757 {
23758 walkable=false;
23759 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23760 switch(tdir)
23761 {
23762 case left:
23763 --x;
23764 break;
23765 case right:
23766 ++x;
23767 break;
23768 case up:
23769 --y;
23770 break;
23771 case down:
23772 ++y;
23773 break;
23774 }
23775 }
23776 else
23777 {
23778
2/4
✓ Branch 0 taken 46771 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46771 times.
46771 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23779 {
23780 s-=1.5;
23781 }
23782
2/2
✓ Branch 0 taken 27297 times.
✓ Branch 1 taken 19474 times.
46771 else if(dir<left)
23783 {
23784 27297 s-=lsteps[y.getInt()&7];
23785 27297 }
23786 else
23787 {
23788 19474 s-=lsteps[x.getInt()&7];
23789 }
23790
23791 46771 move(dir, 150);
23792 }
23793 }
23794
23795
2/2
✓ Branch 0 taken 44181 times.
✓ Branch 1 taken 2590 times.
46771 if(s<0)
23796 {
23797 // Not quite sure how this is actually supposed to work.
23798 // There have to be two cases for each direction or Hero
23799 // either walks too far onto the screen or may get stuck
23800 // going through walk-through walls.
23801
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 597 times.
✓ Branch 3 taken 431 times.
✓ Branch 4 taken 575 times.
2590 switch(dir)
23802 {
23803 case up:
23804
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 924 times.
987 if(y<8) // Leaving the screen
23805 63 y+=s;
23806 else // Entering the screen
23807 924 y-=s;
23808
23809 987 break;
23810
23811 case down:
23812
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 543 times.
597 if(y>152)
23813 54 y-=s;
23814 else
23815 543 y+=s;
23816
23817 597 break;
23818
23819 case left:
23820
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 387 times.
431 if(x<8)
23821 44 x+=s;
23822 else
23823 387 x-=s;
23824
23825 431 break;
23826
23827 case right:
23828
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 518 times.
575 if(x>=232)
23829 57 x-=s;
23830 else
23831 518 x+=s;
23832
23833 575 break;
23834 }
23835 2590 }
23836
23837
23838 46771 draw_screen(tmpscr);
23839
1/2
✓ Branch 0 taken 46771 times.
✗ Branch 1 not taken.
46771 if (canSideviewLadder()) setOnSideviewLadder(true);
23840 46771 advanceframe(true);
23841
23842
1/2
✓ Branch 0 taken 46771 times.
✗ Branch 1 not taken.
46771 if(Quit)
23843 return;
23844 }
23845
4/4
✓ Branch 0 taken 2015 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 597 times.
✓ Branch 3 taken 1418 times.
2590 if(dir==right||dir==down)
23846 {
23847 1172 x=int32_t(x);
23848 1172 y=int32_t(y);
23849 1172 }
23850 else
23851 {
23852 1418 x = x.getInt();
23853 1418 y = y.getInt();
23854 }
23855 2590 set_respawn_point();
23856 2590 draw_screen(tmpscr);
23857 2590 eat_buttons();
23858 2590 shiftdir=sh;
23859 2590 }
23860
23861 117 void HeroClass::walkdown(bool opening) //entering cave
23862 {
23863
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 88 times.
117 if(opening)
23864 {
23865 88 close_black_opening(x+8, y+8+playing_field_offset, false);
23866 88 }
23867
23868 117 hclk=0;
23869 117 stop_item_sfx(itype_brang);
23870 117 sfx(WAV_STAIRS,pan(x.getInt()));
23871 117 clk=0;
23872 // int32_t cmby=(y.getInt()&0xF0)+16;
23873 // Fix Hero's position to the grid
23874 117 y=y.getInt()&0xF0;
23875 117 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23876 117 attack=wNone;
23877 117 attackid=-1;
23878 117 reset_swordcharge();
23879 117 climb_cover_x=x.getInt()&0xF0;
23880 117 climb_cover_y=(y.getInt()&0xF0)+16;
23881
23882 117 guys.clear();
23883 117 chainlinks.clear();
23884 117 Lwpns.clear();
23885 117 Ewpns.clear();
23886 117 items.clear();
23887
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 7488 times.
7605 for(int32_t i=0; i<64; i++)
23888 {
23889 7488 herostep();
23890
23891
2/4
✓ Branch 0 taken 7488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7488 times.
7488 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23892 hero_count=(hero_count+1)%16;
23893
23894
2/2
✓ Branch 0 taken 5616 times.
✓ Branch 1 taken 1872 times.
7488 if((i&3)==3)
23895 1872 ++y;
23896
23897 7488 draw_screen(tmpscr);
23898 7488 advanceframe(true);
23899
23900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7488 times.
7488 if(Quit)
23901 break;
23902 7488 }
23903
23904 117 action=none; FFCore.setHeroAction(none);
23905 117 }
23906
23907 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
23908 {
23909 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23910
23911
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
23912 y-=16;
23913
23914 21 dir=down;
23915 // Fix Hero's position to the grid
23916 21 y=y.getInt()&0xF0;
23917 21 z=fakez=fall=fakefall=0;
23918
23919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
23920 {
23921 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
23922 21 }
23923
23924 21 hclk=0;
23925 21 stop_item_sfx(itype_brang);
23926 21 sfx(WAV_STAIRS,pan(x.getInt()));
23927 21 clk=0;
23928 // int32_t cmby=y.getInt()&0xF0;
23929 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23930 21 attack=wNone;
23931 21 attackid=-1;
23932 21 reset_swordcharge();
23933 21 climb_cover_x=x.getInt()&0xF0;
23934 21 climb_cover_y=y.getInt()&0xF0;
23935
23936 21 guys.clear();
23937 21 chainlinks.clear();
23938 21 Lwpns.clear();
23939 21 Ewpns.clear();
23940 21 items.clear();
23941
23942
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
23943 {
23944 1344 herostep();
23945
23946
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23947 hero_count=(hero_count+1)%16;
23948
23949
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
23950 336 ++y;
23951
23952 1344 draw_screen(tmpscr);
23953 1344 advanceframe(true);
23954
23955
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
23956 break;
23957 1344 }
23958
23959 21 action=none; FFCore.setHeroAction(none);
23960 21 }
23961
23962 99 void HeroClass::walkup(bool opening) //exiting cave
23963 {
23964 99 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23965
23966
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
99 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
23967 y+=16;
23968
23969 // Fix Hero's position to the grid
23970 99 y=y.getInt()&0xF0;
23971 99 z=fakez=fall=fakefall=0;
23972
23973
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(opening)
23974 {
23975 77 open_black_opening(x+8, y+8+playing_field_offset-16, false);
23976 77 }
23977
23978 99 hclk=0;
23979 99 stop_item_sfx(itype_brang);
23980 99 sfx(WAV_STAIRS,pan(x.getInt()));
23981 99 dir=down;
23982 99 clk=0;
23983 // int32_t cmby=y.getInt()&0xF0;
23984 99 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23985 99 attack=wNone;
23986 99 attackid=-1;
23987 99 reset_swordcharge();
23988 99 climb_cover_x=x.getInt()&0xF0;
23989 99 climb_cover_y=y.getInt()&0xF0;
23990
23991 99 guys.clear();
23992 99 chainlinks.clear();
23993 99 Lwpns.clear();
23994 99 Ewpns.clear();
23995 99 items.clear();
23996
23997
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 6336 times.
6435 for(int32_t i=0; i<64; i++)
23998 {
23999 6336 herostep();
24000
24001
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24002 hero_count=(hero_count+1)%16;
24003
24004
2/2
✓ Branch 0 taken 4752 times.
✓ Branch 1 taken 1584 times.
6336 if((i&3)==0)
24005 1584 --y;
24006
24007 6336 draw_screen(tmpscr);
24008 6336 advanceframe(true);
24009
24010
1/2
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
6336 if(Quit)
24011 break;
24012 6336 }
24013 99 map_bkgsfx(true);
24014 99 loadside=dir^1;
24015 99 action=none; FFCore.setHeroAction(none);
24016 99 }
24017
24018 22 void HeroClass::walkup2(bool opening) //entering cave2
24019 {
24020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(opening)
24021 {
24022 22 close_black_opening(x+8, y+8+playing_field_offset, false);
24023 22 }
24024
24025 22 hclk=0;
24026 22 stop_item_sfx(itype_brang);
24027 22 sfx(WAV_STAIRS,pan(x.getInt()));
24028 22 dir=up;
24029 22 clk=0;
24030 // int32_t cmby=y.getInt()&0xF0;
24031 22 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
24032 22 attack=wNone;
24033 22 attackid=-1;
24034 22 reset_swordcharge();
24035 22 climb_cover_x=x.getInt()&0xF0;
24036 22 climb_cover_y=(y.getInt()&0xF0)-16;
24037
24038 22 guys.clear();
24039 22 chainlinks.clear();
24040 22 Lwpns.clear();
24041 22 Ewpns.clear();
24042 22 items.clear();
24043
24044
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1408 times.
1430 for(int32_t i=0; i<64; i++)
24045 {
24046 1408 herostep();
24047
24048
2/4
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1408 times.
1408 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24049 hero_count=(hero_count+1)%16;
24050
24051
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 352 times.
1408 if((i&3)==0)
24052 352 --y;
24053
24054 1408 draw_screen(tmpscr);
24055 1408 advanceframe(true);
24056
24057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
1408 if(Quit)
24058 break;
24059 1408 }
24060 22 map_bkgsfx(true);
24061 22 loadside=dir^1;
24062 22 action=none; FFCore.setHeroAction(none);
24063 22 }
24064
24065 214 void HeroClass::stepout() // Step out of item cellars and passageways
24066 {
24067 214 int32_t sc = specialcave; // This gets erased by ALLOFF()
24068 214 ALLOFF();
24069 214 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
24070 214 map_bkgsfx(false);
24071 214 kill_enemy_sfx();
24072 214 draw_screen(tmpscr,false);
24073 214 fade(sc>=GUYCAVE?10:11,true,false);
24074 214 blackscr(30,true);
24075 214 ringcolor(false);
24076
24077
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 137 times.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 99 times.
214 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
24078 {
24079 99 currdmap=stepoutdmap;
24080 99 currmap=DMaps[currdmap].map;
24081 99 dlevel=DMaps[currdmap].level;
24082
24083 //we might have just left a passage, so be sure to update the CSet record -DD
24084 99 currcset=DMaps[currdmap].color;
24085
24086 99 init_dmap();
24087 99 homescr=stepoutscr;
24088 99 }
24089
24090 214 currscr=homescr;
24091 214 loadscr(0,currdmap,currscr,255,false); // bogus direction
24092 214 draw_screen(tmpscr,false);
24093
24094
3/4
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 3 times.
214 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
24095 {
24096 211 darkroom = naturaldark = false;
24097 211 fade(DMaps[currdmap].color,true,true);
24098 211 }
24099 else
24100 {
24101 3 darkroom = naturaldark = true;
24102
24103
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(get_bit(quest_rules,qr_FADE))
24104 {
24105 1 interpolatedfade();
24106 1 }
24107 else
24108 {
24109 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24110 }
24111 3 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
24112 3 si+=3*48;
24113
24114
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 for(int32_t i=0; i<16; i++)
24115 {
24116 48 RAMpal[CSET(9)+i] = _RGB(si);
24117 48 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
24118 48 si+=3;
24119 48 }
24120 }
24121
24122 214 x = tmpscr->warpreturnx[stepoutwr];
24123 214 y = tmpscr->warpreturny[stepoutwr];
24124
24125
1/2
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
214 if(didpit)
24126 {
24127 didpit=false;
24128 x=pitx;
24129 y=pity;
24130 }
24131
24132
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 208 times.
214 if(x+y == 0)
24133 6 x = y = 80;
24134
24135 214 dir=down;
24136
24137 214 set_respawn_point();
24138
24139 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
24140 214 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
24141
24142
4/6
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 211 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
214 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
24143 {
24144 walkup(false);
24145 }
24146
4/6
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 211 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
214 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
24147 {
24148 walkdown2(false);
24149 }
24150
24151 214 newscr_clk=frame;
24152 214 activated_timed_warp=false;
24153 214 didstuff=0;
24154 214 usecounts.clear();
24155 214 eat_buttons();
24156 214 markBmap(-1);
24157 214 map_bkgsfx(true);
24158
24159
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 27 times.
214 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
24160 {
24161 27 music_stop();
24162 27 playLevelMusic();
24163 27 }
24164
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
24165 {
24166 playLevelMusic();
24167 }
24168
24169 214 loadside=dir^1;
24170 214 }
24171
24172 3816 bool HeroClass::nextcombo_wf(int32_t d2)
24173 {
24174
5/8
✓ Branch 0 taken 3816 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3780 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 3780 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
3816 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
24175 3816 return false;
24176
24177 // assumes Hero is about to scroll screens
24178
24179 int32_t ns = nextscr(d2);
24180
24181 if(ns==0xFFFF)
24182 return false;
24183
24184 // want actual screen index, not game->maps[] index
24185 ns = (ns&127) + (ns>>7)*MAPSCRS;
24186
24187 int32_t cx = x;
24188 int32_t cy = y;
24189
24190 switch(d2)
24191 {
24192 case up:
24193 cy=160;
24194 break;
24195
24196 case down:
24197 cy=0;
24198 break;
24199
24200 case left:
24201 cx=240;
24202 break;
24203
24204 case right:
24205 cx=0;
24206 break;
24207 }
24208
24209 // check lower half of combo
24210 cy += 8;
24211
24212 // from MAPCOMBO()
24213 int32_t cmb = (cy&0xF0)+(cx>>4);
24214
24215 if(cmb>175)
24216 return true;
24217
24218 newcombo c = combobuf[TheMaps[ns].data[cmb]];
24219 bool dried = iswater_type(c.type) && DRIEDLAKE;
24220 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24221 int32_t b=1;
24222
24223 if(cx&8) b<<=2;
24224
24225 if(cy&8) b<<=1;
24226
24227 if((c.walk&b) && !dried && !swim)
24228 return true;
24229
24230 // next block (i.e. cnt==2)
24231 if(!(cx&8))
24232 {
24233 b<<=2;
24234 }
24235 else
24236 {
24237 c = combobuf[TheMaps[ns].data[++cmb]];
24238 dried = iswater_type(c.type) && DRIEDLAKE;
24239 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24240 b=1;
24241
24242 if(cy&8)
24243 {
24244 b<<=1;
24245 }
24246 }
24247
24248 return (c.walk&b) ? !dried && !swim : false;
24249 3816 }
24250
24251 bool HeroClass::nextcombo_solid(int32_t d2)
24252 {
24253 if(toogam || currscr>=128)
24254 return false;
24255
24256 // assumes Hero is about to scroll screens
24257
24258 int32_t ns = nextscr(d2);
24259
24260 if(ns==0xFFFF)
24261 return false;
24262
24263 // want actual screen index, not game->maps[] index
24264 ns = (ns&127) + (ns>>7)*MAPSCRS;
24265 int32_t screen = (ns%MAPSCRS);
24266 int32_t map = (ns - screen) / MAPSCRS;
24267
24268 int32_t cx = x;
24269 int32_t cy = y;
24270
24271 switch(d2)
24272 {
24273 case up:
24274 cy=160;
24275 break;
24276
24277 case down:
24278 cy=0;
24279 break;
24280
24281 case left:
24282 cx=240;
24283 break;
24284
24285 case right:
24286 cx=0;
24287 break;
24288 }
24289
24290 if(d2==up) cy += 8;
24291
24292 if(d2==left||d2==right) cy+=bigHitbox?0:8;
24293
24294 int32_t initcx = cx;
24295 int32_t initcy = cy;
24296 // from MAPCOMBO()
24297
24298 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
24299 {
24300 cx = initcx;
24301 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
24302 {
24303 int32_t cmb = (cy&0xF0)+(cx>>4);
24304
24305 if(cmb>175)
24306 {
24307 return true;
24308 }
24309
24310 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
24311
24312 int32_t b=1;
24313
24314 if(cx&8) b<<=2;
24315
24316 if(cy&8) b<<=1;
24317
24318 //bool bridgedetected = false;
24319
24320 int32_t walk = c.walk;
24321 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
24322 {
24323 for (int32_t m = 0; m <= 1; m++)
24324 {
24325 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
24326 if (cmb.type == cBRIDGE)
24327 {
24328 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
24329 {
24330 int efflag = (cmb.walk & 0xF0)>>4;
24331 int newsolid = (cmb.walk & 0xF);
24332 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
24333 }
24334 else walk &= cmb.walk;
24335 }
24336 else walk |= cmb.walk;
24337 }
24338 }
24339 /*
24340 if (bridgedetected)
24341 {
24342 continue;
24343 }*/
24344
24345 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
24346 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
24347
24348 if((walk&b) && !swim)
24349 {
24350 return true;
24351 }
24352 }
24353
24354 /*
24355 #if 0
24356
24357 //
24358 // next block (i.e. cnt==2)
24359 if(!(cx&8))
24360 {
24361 b<<=2;
24362 }
24363 else
24364 {
24365 c = combobuf[TheMaps[ns].data[++cmb]];
24366 dried = iswater_type(c.type) && DRIEDLAKE;
24367 //swim = iswater_type(c.type) && (current_item(itype_flippers));
24368 b=1;
24369
24370 if(cy&8)
24371 {
24372 b<<=1;
24373 }
24374 }
24375
24376 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24377
24378 if((c.walk&b) && !dried && !swim)
24379 {
24380 return true;
24381 }
24382
24383 cx+=8;
24384
24385 if(cx&7)
24386 {
24387 if(!(cx&8))
24388 {
24389 b<<=2;
24390 }
24391 else
24392 {
24393 c = combobuf[TheMaps[ns].data[++cmb]];
24394 dried = iswater_type(c.type) && DRIEDLAKE;
24395 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24396 b=1;
24397
24398 if(cy&8)
24399 {
24400 b<<=1;
24401 }
24402 }
24403
24404 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24405
24406 if((c.walk&b) && !dried && !swim)
24407 return true;
24408 }
24409
24410 #endif
24411 */
24412 }
24413
24414 return false;
24415 }
24416
24417 2441646 void HeroClass::checkscroll()
24418 {
24419 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
24420
2/4
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441646 times.
✗ Branch 3 not taken.
2441646 if(action == casting||action==sideswimcasting)
24421 return;
24422
24423
1/2
✓ Branch 0 taken 2441646 times.
✗ Branch 1 not taken.
2441646 if(toogam)
24424 {
24425 if(x<0 && (currscr&15)==0) x=0;
24426
24427 if(y<0 && currscr<16) y=0;
24428
24429 if(x>240 && (currscr&15)==15) x=240;
24430
24431 if(y>160 && currscr>=112) y=160;
24432 }
24433
24434
2/2
✓ Branch 0 taken 2440374 times.
✓ Branch 1 taken 1272 times.
2441646 if(y<0)
24435 {
24436 1272 bool doit=true;
24437 1272 y=0;
24438
24439
3/6
✓ Branch 0 taken 1272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1272 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1272 times.
1272 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24440 doit = false;
24441
24442
1/2
✓ Branch 0 taken 1272 times.
✗ Branch 1 not taken.
1272 if(nextcombo_wf(up))
24443 doit=false;
24444
24445
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1272 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
24446 {
24447 if(nextcombo_solid(up))
24448 doit=false;
24449 }
24450
24451
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1272 if(doit || action==inwind)
24452 {
24453
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 1058 times.
1272 if(currscr>=128)
24454 {
24455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
214 if(specialcave >= GUYCAVE)
24456 exitcave();
24457 214 else stepout();
24458 214 }
24459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058 times.
1058 else if(action==inwind)
24460 {
24461 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24462 {
24463 action=none; FFCore.setHeroAction(none);
24464 restart_level();
24465 }
24466 else
24467 {
24468 dowarp(2,up);
24469 }
24470 }
24471
3/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1058 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24472 {
24473 26 sdir=up;
24474 26 dowarp(1,(tmpscr->sidewarpindex)&3);
24475 26 }
24476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 else if(!edge_of_dmap(up))
24477 {
24478 1032 scrolling_map = currmap;
24479 1032 scrollscr(up);
24480
24481
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(tmpscr->flags4&fAUTOSAVE)
24482 {
24483 save_game(true,0);
24484 }
24485
24486
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(tmpscr->flags6&fCONTINUEHERE)
24487 {
24488 lastentrance_dmap = currdmap;
24489 lastentrance = homescr;
24490 }
24491 1032 }
24492 1272 }
24493 1272 }
24494
24495
2/2
✓ Branch 0 taken 2440924 times.
✓ Branch 1 taken 722 times.
2441646 if(y>160)
24496 {
24497 722 bool doit=true;
24498 722 y=160;
24499
24500
3/6
✓ Branch 0 taken 722 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 722 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 722 times.
722 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24501 doit = false;
24502
24503
1/2
✓ Branch 0 taken 722 times.
✗ Branch 1 not taken.
722 if(nextcombo_wf(down))
24504 doit=false;
24505
24506
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
722 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
24507 {
24508 if(nextcombo_solid(down))
24509 doit=false;
24510 }
24511
24512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
722 if(doit || action==inwind)
24513 {
24514
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 599 times.
722 if(currscr>=128)
24515 {
24516
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(specialcave >= GUYCAVE)
24517 123 exitcave();
24518 else stepout();
24519 123 }
24520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
599 else if(action==inwind)
24521 {
24522 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24523 {
24524 action=none; FFCore.setHeroAction(none);
24525 restart_level();
24526 }
24527 else
24528 {
24529 dowarp(2,down);
24530 }
24531 }
24532
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
599 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24533 {
24534 25 sdir=down;
24535 25 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24536 25 }
24537
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 569 times.
574 else if(!edge_of_dmap(down))
24538 {
24539 569 scrolling_map = currmap;
24540 569 scrollscr(down);
24541
24542
1/2
✓ Branch 0 taken 569 times.
✗ Branch 1 not taken.
569 if(tmpscr->flags4&fAUTOSAVE)
24543 {
24544 save_game(true,0);
24545 }
24546
24547
1/2
✓ Branch 0 taken 569 times.
✗ Branch 1 not taken.
569 if(tmpscr->flags6&fCONTINUEHERE)
24548 {
24549 lastentrance_dmap = currdmap;
24550 lastentrance = homescr;
24551 }
24552 569 }
24553 722 }
24554 722 }
24555
24556
2/2
✓ Branch 0 taken 2440839 times.
✓ Branch 1 taken 807 times.
2441646 if(x<0)
24557 {
24558 807 bool doit=true;
24559 807 x=0;
24560
24561
3/6
✓ Branch 0 taken 807 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 807 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 807 times.
807 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24562 doit = false;
24563
24564
1/2
✓ Branch 0 taken 807 times.
✗ Branch 1 not taken.
807 if(nextcombo_wf(left))
24565 doit=false;
24566
24567
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 807 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
807 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
24568 {
24569 if(nextcombo_solid(left))
24570 doit=false;
24571 }
24572
24573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 807 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
807 if(doit || action==inwind)
24574 {
24575
1/2
✓ Branch 0 taken 807 times.
✗ Branch 1 not taken.
807 if(currscr>=128)
24576 {
24577 if(specialcave >= GUYCAVE)
24578 exitcave();
24579 else stepout();
24580 }
24581
24582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 807 times.
807 if(action==inwind)
24583 {
24584 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24585 {
24586 action=none; FFCore.setHeroAction(none);
24587 restart_level();
24588 }
24589 else
24590 {
24591 dowarp(2,left);
24592 }
24593 }
24594
3/6
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 789 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
807 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24595 {
24596 18 sdir=left;
24597 18 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24598 18 }
24599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 789 times.
789 else if(!edge_of_dmap(left))
24600 {
24601 789 scrolling_map = currmap;
24602 789 scrollscr(left);
24603
24604
1/2
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
789 if(tmpscr->flags4&fAUTOSAVE)
24605 {
24606 save_game(true,0);
24607 }
24608
24609
1/2
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
789 if(tmpscr->flags6&fCONTINUEHERE)
24610 {
24611 lastentrance_dmap = currdmap;
24612 lastentrance = homescr;
24613 }
24614 789 }
24615 807 }
24616 807 }
24617
24618
2/2
✓ Branch 0 taken 2440677 times.
✓ Branch 1 taken 969 times.
2441646 if(x>240)
24619 {
24620 969 bool doit=true;
24621 969 x=240;
24622
24623
3/6
✓ Branch 0 taken 969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 969 times.
969 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24624 doit = false;
24625
24626
1/2
✓ Branch 0 taken 969 times.
✗ Branch 1 not taken.
969 if(nextcombo_wf(right))
24627 doit=false;
24628
24629
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 969 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
969 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
24630 {
24631 if(nextcombo_solid(right))
24632 doit=false;
24633 }
24634
24635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 969 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
969 if(doit || action==inwind)
24636 {
24637
1/2
✓ Branch 0 taken 969 times.
✗ Branch 1 not taken.
969 if(currscr>=128)
24638 {
24639 if(specialcave >= GUYCAVE)
24640 exitcave();
24641 else stepout();
24642 }
24643
24644
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 948 times.
969 if(action==inwind)
24645 {
24646
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 20 times.
21 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24647 {
24648 1 action=none; FFCore.setHeroAction(none);
24649 1 restart_level();
24650 1 }
24651 else
24652 {
24653 20 dowarp(2,right);
24654 }
24655 21 }
24656
3/6
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 933 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
948 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24657 {
24658 15 sdir=right;
24659 15 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
24660 15 }
24661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 933 times.
933 else if(!edge_of_dmap(right))
24662 {
24663 933 scrolling_map = currmap;
24664 933 scrollscr(right);
24665
24666
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 if(tmpscr->flags4&fAUTOSAVE)
24667 {
24668 save_game(true,0);
24669 }
24670
24671
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 if(tmpscr->flags6&fCONTINUEHERE)
24672 {
24673 lastentrance_dmap = currdmap;
24674 lastentrance = homescr;
24675 }
24676 933 }
24677 969 }
24678 969 }
24679 2441646 }
24680
24681 // assumes current direction is in lastdir[3]
24682 // compares directions with scr->path and scr->exitdir
24683 9946 bool HeroClass::checkmaze(mapscr *scr, bool sound)
24684 {
24685
2/2
✓ Branch 0 taken 9839 times.
✓ Branch 1 taken 107 times.
9946 if(!(scr->flags&fMAZE))
24686 9839 return true;
24687
24688
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 91 times.
107 if(lastdir[3]==scr->exitdir)
24689 16 return true;
24690
24691
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 18 times.
168 for(int32_t i=0; i<4; i++)
24692
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 73 times.
150 if(lastdir[i]!=scr->path[i])
24693 73 return false;
24694
24695
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(sound)
24696 9 sfx(scr->secretsfx);
24697
24698 18 return true;
24699 9946 }
24700
24701 6623 bool HeroClass::edge_of_dmap(int32_t side)
24702 {
24703
2/2
✓ Branch 0 taken 6578 times.
✓ Branch 1 taken 45 times.
6623 if(checkmaze(tmpscr,false)==false)
24704 45 return false;
24705
24706 // needs fixin'
24707 // should check dmap style
24708
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2032 times.
✓ Branch 2 taken 1131 times.
✓ Branch 3 taken 1555 times.
✓ Branch 4 taken 1860 times.
6578 switch(side)
24709 {
24710 case up:
24711 2032 return currscr<16;
24712
24713 case down:
24714 1131 return currscr>=112;
24715
24716 case left:
24717
1/2
✓ Branch 0 taken 1555 times.
✗ Branch 1 not taken.
1555 if((currscr&15)==0)
24718 return true;
24719
24720
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 745 times.
1555 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24721 // if(dlevel)
24722 810 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
24723
24724 745 break;
24725
24726 case right:
24727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1860 times.
1860 if((currscr&15)==15)
24728 return true;
24729
24730
2/2
✓ Branch 0 taken 1053 times.
✓ Branch 1 taken 807 times.
1860 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24731 // if(dlevel)
24732 1053 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
24733
24734 807 break;
24735 }
24736
24737 1552 return false;
24738 6623 }
24739
24740 71 bool HeroClass::lookaheadraftflag(int32_t d2)
24741 {
24742 // Helper for scrollscr that gets next combo on next screen.
24743 // Can use destscr for scrolling warps,
24744 // but assumes currmap is correct.
24745
24746 71 int32_t cx = x;
24747 71 int32_t cy = y + 8;
24748
24749 71 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24750 71 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24751 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24752 //Applying this here, too. -Z
24753
24754
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 20 times.
71 switch(d2)
24755 {
24756 case up:
24757 22 cy=160;
24758 22 break;
24759
24760 case down:
24761 15 cy=0;
24762 15 break;
24763
24764 case left:
24765 14 cx=240;
24766 14 break;
24767
24768 case right:
24769 20 cx=0;
24770 20 break;
24771 }
24772
24773 71 int32_t combo = (cy&0xF0)+(cx>>4);
24774
24775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(combo>175)
24776 return 0;
24777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
24778
24779 71 }
24780 3361 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
24781 {
24782 // Can use destscr for scrolling warps,
24783 // but assumes currmap is correct.
24784
24785 3361 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
24786 3361 int32_t cy = vbound(y + 8,0,160);
24787 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24788 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24789 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24790
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1038 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 791 times.
✓ Branch 4 taken 956 times.
3361 switch(d2)
24791 {
24792 case up:
24793 1038 cy=160;
24794 1038 break;
24795
24796 case down:
24797 576 cy=0;
24798 576 break;
24799
24800 case left:
24801 791 cx=240;
24802 791 break;
24803
24804 case right:
24805 956 cx=0;
24806 956 break;
24807 }
24808
24809 3361 int32_t combo = (cy&0xF0)+(cx>>4);
24810
24811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(combo>175)
24812 return 0;
24813
24814 3361 return tmpscr[0].data[combo]; // entire combo code
24815 3361 }
24816
24817 3361 int32_t HeroClass::lookaheadflag(int32_t d2)
24818 {
24819 // Helper for scrollscr that gets next combo on next screen.
24820 // Can use destscr for scrolling warps,
24821 // but assumes currmap is correct.
24822
24823 3361 int32_t cx = vbound(x,0,240);
24824 3361 int32_t cy = vbound(y + 8,0,160);
24825
24826 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24827 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24828 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24829 //Applying this here, too. -Z
24830
24831
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1038 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 791 times.
✓ Branch 4 taken 956 times.
3361 switch(d2)
24832 {
24833 case up:
24834 1038 cy=160;
24835 1038 break;
24836
24837 case down:
24838 576 cy=0;
24839 576 break;
24840
24841 case left:
24842 791 cx=240;
24843 791 break;
24844
24845 case right:
24846 956 cx=0;
24847 956 break;
24848 }
24849
24850 3361 int32_t combo = (cy&0xF0)+(cx>>4);
24851
24852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(combo>175)
24853 return 0;
24854
24855
2/2
✓ Branch 0 taken 3262 times.
✓ Branch 1 taken 99 times.
3361 if(!tmpscr[0].sflag[combo])
24856 {
24857 3262 return combobuf[tmpscr[0].data[combo]].flag; // flag
24858 }
24859
24860 99 return tmpscr[0].sflag[combo]; // flag
24861 3361 }
24862
24863 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
24864 531787 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
24865 {
24866 // For rafting (and possibly other esoteric things)
24867 // Hero's action should remain unchanged while scrolling,
24868 // but for the sake of scripts, here's an eye-watering kludge.
24869 531787 actiontype lastaction = action;
24870 531787 action=scrolling; FFCore.setHeroAction(scrolling);
24871
2/2
✓ Branch 0 taken 265887 times.
✓ Branch 1 taken 265900 times.
531787 if(waitdraw)
24872 {
24873 265887 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
24874 265887 }
24875 else
24876 {
24877 265900 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
24878 }
24879 531787 zfix storex = x, storey = y;
24880
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 143325 times.
✓ Branch 2 taken 76997 times.
✓ Branch 3 taken 140623 times.
✓ Branch 4 taken 170842 times.
531787 switch(scrolldir)
24881 {
24882 case up:
24883
2/2
✓ Branch 0 taken 121488 times.
✓ Branch 1 taken 21837 times.
143325 if(y < 160) y = 176;
24884
4/4
✓ Branch 0 taken 18865 times.
✓ Branch 1 taken 2972 times.
✓ Branch 2 taken 6265 times.
✓ Branch 3 taken 12600 times.
21837 else if(cx > 0 && !end_frames) y = sy + 156;
24885 9237 else y = 160;
24886
24887 143325 break;
24888
24889 case down:
24890
2/2
✓ Branch 0 taken 64946 times.
✓ Branch 1 taken 12051 times.
76997 if(y > 0) y = -16;
24891
4/4
✓ Branch 0 taken 10362 times.
✓ Branch 1 taken 1689 times.
✓ Branch 2 taken 3752 times.
✓ Branch 3 taken 6610 times.
12051 else if(cx > 0 && !end_frames) y = sy - 172;
24892 5441 else y = 0;
24893
24894 76997 break;
24895
24896 case left:
24897
2/2
✓ Branch 0 taken 129681 times.
✓ Branch 1 taken 10942 times.
140623 if(x < 240) x = 256;
24898
2/2
✓ Branch 0 taken 9355 times.
✓ Branch 1 taken 1587 times.
10942 else if(cx > 0) x = sx + 236;
24899 1587 else x = 240;
24900
24901 140623 break;
24902
24903 case right:
24904
2/2
✓ Branch 0 taken 157568 times.
✓ Branch 1 taken 13274 times.
170842 if(x > 0) x = -16;
24905
2/2
✓ Branch 0 taken 11356 times.
✓ Branch 1 taken 1918 times.
13274 else if(cx > 0) x = sx - 252;
24906 1918 else x = 0;
24907
24908 170842 break;
24909 }
24910
2/2
✓ Branch 0 taken 265887 times.
✓ Branch 1 taken 265900 times.
531787 if(waitdraw)
24911 {
24912
3/4
✓ Branch 0 taken 265887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 217477 times.
✓ Branch 3 taken 48410 times.
265887 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
24913 {
24914 48410 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24915 48410 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
24916 48410 }
24917 265887 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
24918
2/6
✓ Branch 0 taken 265887 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265887 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
265887 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24919 {
24920 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24921 player_waitdraw = false;
24922 }
24923 265887 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
24924
2/6
✓ Branch 0 taken 265887 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265887 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
265887 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24925 {
24926 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24927 dmap_waitdraw = false;
24928 }
24929 265887 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
24930
2/6
✓ Branch 0 taken 265887 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265887 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
265887 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24931 {
24932 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24933 passive_subscreen_waitdraw = false;
24934 }
24935 265887 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
24936
2/10
✓ Branch 0 taken 265887 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265887 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
265887 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24937 {
24938 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24939 tmpscr->screen_waitdraw = 0;
24940 }
24941 265887 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
24942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265887 times.
265887 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
24943 {
24944 265887 FFCore.itemScriptEngineOnWaitdraw();
24945 265887 }
24946 265887 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
24947 265887 }
24948 else
24949 {
24950
2/8
✓ Branch 0 taken 265900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265900 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
265900 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24951 {
24952 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24953 }
24954 265900 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
24955
3/4
✓ Branch 0 taken 265900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216638 times.
✓ Branch 3 taken 49262 times.
265900 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
24956 {
24957 49262 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24958 49262 }
24959 265900 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
24960
4/6
✓ Branch 0 taken 265900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265048 times.
✓ Branch 3 taken 852 times.
✓ Branch 4 taken 265048 times.
✗ Branch 5 not taken.
265900 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
24961 {
24962 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24963 }
24964 265900 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
24965
4/6
✓ Branch 0 taken 265900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265048 times.
✓ Branch 5 taken 852 times.
265900 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24966 {
24967 852 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24968 852 }
24969 265900 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
24970
4/6
✓ Branch 0 taken 265900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265048 times.
✓ Branch 5 taken 852 times.
265900 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24971 {
24972 852 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24973 852 }
24974 265900 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
24975 265900 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
24976
3/4
✓ Branch 0 taken 265900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 852 times.
✓ Branch 3 taken 265048 times.
265900 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
24977 265048 FFCore.itemScriptEngine();
24978 265900 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
24979
3/4
✓ Branch 0 taken 265900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265048 times.
✓ Branch 3 taken 852 times.
265900 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
24980 852 FFCore.itemScriptEngine();
24981 }
24982
24983 531787 x = storex, y = storey;
24984
24985 531787 action=lastaction; FFCore.setHeroAction(lastaction);
24986 531787 }
24987
24988 //Has solving the maze enabled a side warp?
24989 //Only used just before scrolling screens
24990 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
24991 // return true to abort the topmost scrollscr() call. -L
24992 3361 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
24993 {
24994
2/2
✓ Branch 0 taken 10083 times.
✓ Branch 1 taken 3361 times.
13444 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
24995
24996
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 3316 times.
3361 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
24997
24998
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3361 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
24999 {
25000 switch(scrolldir)
25001 {
25002 case up:
25003 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
25004 {
25005 lastdir[3] = 0xFF;
25006 sdir=up;
25007 dowarp(1,(tmpscr->sidewarpindex)&3);
25008 return true;
25009 }
25010
25011 break;
25012
25013 case down:
25014 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
25015 {
25016 lastdir[3] = 0xFF;
25017 sdir=down;
25018 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
25019 return true;
25020 }
25021
25022 break;
25023
25024 case left:
25025 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
25026 {
25027 lastdir[3] = 0xFF;
25028 sdir=left;
25029 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
25030 return true;
25031 }
25032
25033 break;
25034
25035 case right:
25036 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
25037 {
25038 lastdir[3] = 0xFF;
25039 sdir=right;
25040 dowarp(1,(tmpscr->sidewarpindex)&3);
25041 return true;
25042 }
25043
25044 break;
25045 }
25046 }
25047
25048 3361 return false;
25049 3361 }
25050
25051 3361 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
25052 {
25053 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
25054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
25055 return 16;
25056
25057
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 385 times.
3361 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
25058 {
25059
2/2
✓ Branch 0 taken 1308 times.
✓ Branch 1 taken 1668 times.
2976 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25060 }
25061 else
25062 {
25063
4/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 202 times.
385 if(scrolldir == up || scrolldir == down)
25064 {
25065 183 return 8;
25066 }
25067 else
25068 {
25069
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 102 times.
202 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25070 }
25071 }
25072 3361 }
25073
25074 3361 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
25075 {
25076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(get_bit(quest_rules, qr_NOSCROLL))
25077 return 0;
25078
25079
3/4
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2976 times.
✓ Branch 3 taken 385 times.
3361 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
25080 3361 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
25081 {
25082 2976 return 1;
25083 }
25084 else
25085 {
25086
4/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 202 times.
385 if(scrolldir == up || scrolldir == down)
25087 {
25088
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 81 times.
183 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
25089 }
25090 else
25091 {
25092 202 return 1;
25093 }
25094 }
25095 3361 }
25096
25097 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
25098 {
25099 int32_t itemid = current_item_id(itype_lantern);
25100 if(itemid < 0) return; //no lantern light circle
25101 int32_t hx1 = x.getInt() - x1 + 8;
25102 int32_t hy1 = y.getInt() - y1 + 8;
25103 int32_t hx2 = x.getInt() - x2 + 8;
25104 int32_t hy2 = y.getInt() - y2 + 8;
25105
25106 itemdata& lamp = itemsbuf[itemid];
25107 switch(lamp.misc1) //Shape
25108 {
25109 case 0: //Circle
25110 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
25111 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
25112 break;
25113 case 1: //Lamp Cone
25114 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
25115 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
25116 break;
25117 }
25118 }
25119
25120 3361 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
25121 {
25122
2/4
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3361 times.
3361 if(action==freeze||action==sideswimfreeze)
25123 {
25124 return;
25125 }
25126
25127 3361 bool overlay = false;
25128
25129
2/4
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3361 times.
3361 if(scrolldir >= 0 && scrolldir <= 3)
25130 {
25131 3361 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
25132 3361 }
25133
25134
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 3323 times.
3361 if(destdmap == -1)
25135 {
25136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3323 times.
3323 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
25137
1/2
✓ Branch 0 taken 3323 times.
✗ Branch 1 not taken.
3323 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
25138 return;
25139 3323 }
25140 else
25141 {
25142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
25143
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
25144 return;
25145 }
25146
25147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
25148 return;
25149
25150 3361 kill_enemy_sfx();
25151 3361 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25152 3361 screenscrolling = true;
25153 3361 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
25154
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1038 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 791 times.
✓ Branch 4 taken 956 times.
3361 switch(scrolldir)
25155 {
25156 case up:
25157 1038 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25158 1038 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
25159 1038 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25160 1038 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25161 1038 break;
25162 case down:
25163 576 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25164 576 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
25165 576 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25166 576 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25167 576 break;
25168 case left:
25169 791 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
25170 791 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25171 791 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25172 791 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25173 791 break;
25174 case right:
25175 956 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
25176 956 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25177 956 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25178 956 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25179 956 break;
25180 }
25181 3361 FFCore.init_combo_doscript();
25182 3361 tmpscr[1] = tmpscr[0];
25183
25184 3361 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
25185
25186
2/2
✓ Branch 0 taken 20166 times.
✓ Branch 1 taken 3361 times.
23527 for(int32_t i = 0; i < 6; i++)
25187 {
25188 20166 tmpscr3[i] = tmpscr2[i];
25189 20166 }
25190
25191 3361 conveyclk = 2;
25192
25193 3361 mapscr *newscr = &tmpscr[0];
25194 3361 mapscr *oldscr = &tmpscr[1];
25195
25196 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
25197 3361 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
25198 3361 int32_t cx = 0;
25199 3361 int32_t step = get_scroll_step(scrolldir);
25200 3361 int32_t delay = get_scroll_delay(scrolldir);
25201 3361 bool end_frames = false;
25202
25203 3361 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
25204
1/2
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
3361 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
25205 scx = 32; //for sideview very fast screolling.
25206
25207
25208 3361 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
25209 3361 actiontype lastaction = action;
25210 3361 ALLOFF(false, false);
25211 // for now, restore Hero's previous action
25212
2/2
✓ Branch 0 taken 3348 times.
✓ Branch 1 taken 13 times.
3361 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
25213 3361 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
25214 3361 action=lastaction; FFCore.setHeroAction(lastaction);
25215
25216 3361 lstep = (lstep + 6) % 12;
25217 3361 cx = scx;
25218 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
25219
3/4
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2530 times.
✓ Branch 3 taken 831 times.
3361 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
25220 {
25221 831 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25222 831 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
25223 831 }
25224 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
25225
2/6
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3361 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3361 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25226 {
25227 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25228 player_waitdraw = false;
25229 }
25230 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
25231
2/6
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3361 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3361 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25232 {
25233 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25234 dmap_waitdraw = false;
25235 }
25236 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
25237
2/6
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3361 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3361 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25238 {
25239 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25240 passive_subscreen_waitdraw = false;
25241 }
25242 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
25243
2/8
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3361 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3361 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25244 {
25245 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25246 tmpscr->screen_waitdraw = 0;
25247 }
25248 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
25249
25250 3361 word c = tmpscr->numFFC();
25251
2/2
✓ Branch 0 taken 107312 times.
✓ Branch 1 taken 3361 times.
110673 for ( word q = 0; q < c; ++q )
25252 {
25253 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
25254
1/2
✓ Branch 0 taken 107312 times.
✗ Branch 1 not taken.
107312 if ( tmpscr->ffcswaitdraw&(1<<q) )
25255 {
25256 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
25257 if(tmpscr->ffcs[q].script != 0)
25258 {
25259 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
25260 tmpscr->ffcswaitdraw &= ~(1<<q);
25261 }
25262 }
25263 107312 }
25264 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
25265 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
25266 //Waitdraw for item scripts.
25267 3361 FFCore.itemScriptEngineOnWaitdraw();
25268 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
25269 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
25270
25271 //Sprite scripts on Waitdraw
25272 3361 FFCore.eweaponScriptEngineOnWaitdraw();
25273 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
25274 3361 FFCore.itemSpriteScriptEngineOnWaitdraw();
25275 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
25276
25277 //This is no longer a do-while, as the first iteration is now slightly different. -Em
25278 3361 draw_screen(tmpscr,true,true);
25279
25280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(cx == scx)
25281 3361 rehydratelake(false);
25282
25283 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25284 3361 advanceframe(true);
25285
25286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(Quit)
25287 {
25288 screenscrolling = false;
25289 return;
25290 }
25291
25292 3361 ++cx;
25293
2/2
✓ Branch 0 taken 74221 times.
✓ Branch 1 taken 3361 times.
77582 while(cx < 32)
25294 {
25295
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 74208 times.
74221 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
25296 {
25297 13 script_drawing_commands.Clear();
25298 13 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25299 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
25300 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25301 13 }
25302 74208 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25303 74221 draw_screen(tmpscr,true,true);
25304
25305
1/2
✓ Branch 0 taken 74221 times.
✗ Branch 1 not taken.
74221 if(cx == scx)
25306 rehydratelake(false);
25307
25308 74221 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25309 74221 advanceframe(true);
25310
25311
1/2
✓ Branch 0 taken 74221 times.
✗ Branch 1 not taken.
74221 if(Quit)
25312 {
25313 screenscrolling = false;
25314 return;
25315 }
25316
25317 74221 ++cx;
25318 }
25319 3361 script_drawing_commands.Clear();
25320 3361 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25321
25322
25323 //clear Hero's last hits
25324 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
25325
25326
3/4
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 1870 times.
3361 switch(DMaps[currdmap].type&dmfTYPE)
25327 {
25328 case dmDNGN:
25329
1/2
✓ Branch 0 taken 1870 times.
✗ Branch 1 not taken.
1870 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
25330 {
25331 markBmap(scrolldir);
25332 }
25333 1870 break;
25334 case dmOVERW: case dmBSOVERW:
25335
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1427 times.
1440 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
25336 1427 break;
25337 [[fallthrough]];
25338 case dmCAVE:
25339 64 markBmap(scrolldir);
25340 64 break;
25341 }
25342
25343
1/2
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
3361 if(fixed_door)
25344 {
25345 unsetmapflag(mSECRET);
25346 fixed_door = false;
25347 }
25348 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
25349 3361 scrolling_scr = currscr;
25350
25351
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1038 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 791 times.
✓ Branch 4 taken 956 times.
3361 switch(scrolldir)
25352 {
25353 case up:
25354 {
25355
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1032 times.
1038 if(destscr != -1)
25356 6 currscr = destscr;
25357
3/4
✓ Branch 0 taken 1017 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1017 times.
1032 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25358 1017 currscr -= 16;
25359
25360 1038 loadscr(0,destdmap,currscr,scrolldir,overlay);
25361 1038 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
25362 1038 putscr(scrollbuf,0,0,newscr);
25363 1038 putscrdoors(scrollbuf,0,0,newscr);
25364 1038 sy=176;
25365
25366
2/2
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 143 times.
1038 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25367 143 sy+=3;
25368
25369 1038 cx=176/step;
25370 1038 FFCore.init_combo_doscript();
25371 }
25372 1038 break;
25373
25374 case down:
25375 {
25376
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 569 times.
576 if(destscr != -1)
25377 7 currscr = destscr;
25378
3/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 563 times.
569 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25379 563 currscr += 16;
25380
25381 576 loadscr(0,destdmap,currscr,scrolldir,overlay);
25382 576 putscr(scrollbuf,0,176,newscr);
25383 576 putscrdoors(scrollbuf,0,176,newscr);
25384 576 sy = 0;
25385
25386
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 40 times.
576 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25387 40 sy+=3;
25388
25389 576 cx = 176 / step;
25390 576 FFCore.init_combo_doscript();
25391 }
25392 576 break;
25393
25394 case left:
25395 {
25396
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 789 times.
791 if(destscr!=-1)
25397 2 currscr = destscr;
25398
3/4
✓ Branch 0 taken 783 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 783 times.
789 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25399 783 --currscr;
25400
25401 791 loadscr(0,destdmap,currscr,scrolldir,overlay);
25402 791 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
25403 791 putscr(scrollbuf,0,0,newscr);
25404 791 putscrdoors(scrollbuf,0,0,newscr);
25405 791 sx = 256;
25406 791 cx = 256 / step;
25407 791 FFCore.init_combo_doscript();
25408 }
25409 791 break;
25410
25411 case right:
25412 {
25413
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 933 times.
956 if(destscr != -1)
25414 23 currscr = destscr;
25415
3/4
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 932 times.
933 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25416 932 ++currscr;
25417
25418 956 loadscr(0,destdmap,currscr,scrolldir,overlay);
25419 956 putscr(scrollbuf,256,0,newscr);
25420 956 putscrdoors(scrollbuf,256,0,tmpscr);
25421 956 sx = 0;
25422 956 cx = 256 / step;
25423 956 FFCore.init_combo_doscript();
25424 }
25425 956 break;
25426 }
25427
25428 // change Hero's state if entering water
25429 3361 int32_t ahead = lookahead(scrolldir);
25430 3361 int32_t aheadflag = lookaheadflag(scrolldir);
25431 3361 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
25432 3361 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
25433 3361 int32_t wateraheadx1 = vbound(x+4,0,240);
25434 3361 int32_t wateraheadx2 = vbound(x+11,0,240);;
25435 3361 int32_t wateraheady1 = vbound(y+9,0,160);
25436 3361 int32_t wateraheady2 = vbound(y+15,0,160);
25437 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25438 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25439 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
25440
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1038 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 791 times.
✓ Branch 4 taken 956 times.
3361 switch(scrolldir)
25441 {
25442 case up:
25443 1038 lookaheady=160;
25444 1038 wateraheady1=160;
25445 1038 wateraheady2=160;
25446 1038 break;
25447
25448 case down:
25449 576 lookaheady=0;
25450 576 wateraheady1=0;
25451 576 wateraheady2=0;
25452 576 break;
25453
25454 case left:
25455 791 lookaheadx=240;
25456 791 wateraheadx1=240;
25457 791 wateraheadx2=240;
25458 791 break;
25459
25460 case right:
25461 956 lookaheadx=0;
25462 956 wateraheadx1=0;
25463 956 wateraheadx2=0;
25464 956 break;
25465 }
25466
25467 3361 bool nowinwater = false;
25468
25469
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3341 times.
3361 if(lastaction != inwind)
25470 {
25471
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 3270 times.
3341 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
25472 {
25473
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 64 times.
71 if (lookaheadraftflag(scrolldir))
25474 {
25475 64 action=rafting; FFCore.setHeroAction(rafting);
25476 64 raftclk=0;
25477 64 }
25478 71 }
25479
5/6
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 3224 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 30 times.
3270 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
25480 {
25481
9/16
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
30 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
25482 {
25483 29 SetSwim();
25484 29 hopclk = 0xFF;
25485 29 nowinwater = true;
25486 29 }
25487 else
25488 {
25489 1 action=hopping; FFCore.setHeroAction(hopping);
25490 1 hopclk = 2;
25491 1 nowinwater = true;
25492 }
25493 30 }
25494
2/4
✓ Branch 0 taken 3240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3240 times.
3240 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
25495 {
25496 action = lastaction; FFCore.setHeroAction(lastaction);
25497 }
25498 else
25499 {
25500 3240 action=none; FFCore.setHeroAction(none);
25501 }
25502 3341 }
25503
25504 // The naturaldark state can be read/set by an FFC script before
25505 // fade() or lighting() is called.
25506 3361 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
25507
25508
2/2
✓ Branch 0 taken 3275 times.
✓ Branch 1 taken 86 times.
3361 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
25509
25510
2/2
✓ Branch 0 taken 3249 times.
✓ Branch 1 taken 112 times.
3361 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
25511 //Preloaded ffc scripts
25512 3361 homescr=currscr;
25513 3361 auto olddmap = currdmap;
25514
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 3323 times.
3361 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
25515
25516 3361 currdmap = newdmap;
25517 3361 ffscript_engine(true);
25518 3361 currdmap = olddmap;
25519
25520 // There are two occasions when scrolling must be darkened:
25521 // 1) When scrolling into a dark room.
25522 // 2) When scrolling between DMaps of different colours.
25523
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 3323 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
3361 if(destdmap != -1 && DMaps[destdmap].color != currcset)
25524 {
25525 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
25526 darkroom = true;
25527 }
25528
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 3253 times.
3361 else if(!darkroom)
25529 3253 lighting(false, false); // NES behaviour: fade to dark before scrolling
25530
25531
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 3290 times.
3361 if(action != rafting) // Is this supposed to be here?!
25532
25533 3290 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
25534
25535 3361 cx *= delay; //so we can have drawing re-done every frame,
25536 //previously it was for(0 to delay) advanceframes at end of loop
25537 3361 int32_t no_move = 0;
25538
25539 3361 currdmap = newdmap;
25540
4/4
✓ Branch 0 taken 3361 times.
✓ Branch 1 taken 265874 times.
✓ Branch 2 taken 265874 times.
✓ Branch 3 taken 3361 times.
269235 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
25541 {
25542
3/4
✓ Branch 0 taken 265874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144425 times.
✓ Branch 3 taken 121449 times.
265874 if (replay_is_active() && replay_get_version() < 3)
25543 {
25544 121449 replay_poll();
25545 121449 }
25546
1/2
✓ Branch 0 taken 265874 times.
✗ Branch 1 not taken.
265874 if(Quit)
25547 {
25548 screenscrolling = false;
25549 return;
25550 }
25551
25552
25553 265874 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
25554
25555
2/2
✓ Branch 0 taken 247261 times.
✓ Branch 1 taken 18613 times.
265874 if(no_move > 0)
25556 18613 no_move--;
25557
25558 //Don't want to move things on the first or last iteration, or between delays
25559
6/6
✓ Branch 0 taken 262513 times.
✓ Branch 1 taken 3361 times.
✓ Branch 2 taken 257721 times.
✓ Branch 3 taken 4792 times.
✓ Branch 4 taken 9122 times.
✓ Branch 5 taken 248599 times.
265874 if(i == 0 || cx == 0 || cx % delay != 0)
25560 17275 no_move++;
25561
25562
4/4
✓ Branch 0 taken 194213 times.
✓ Branch 1 taken 71661 times.
✓ Branch 2 taken 38497 times.
✓ Branch 3 taken 155716 times.
265874 if(scrolldir == up || scrolldir == down)
25563 {
25564
2/2
✓ Branch 0 taken 96463 times.
✓ Branch 1 taken 13695 times.
110158 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
25565 {
25566 //Add a few extra frames if on the second loop and cool scrolling is not set
25567
2/2
✓ Branch 0 taken 13512 times.
✓ Branch 1 taken 183 times.
13695 if(i == 1)
25568 {
25569 183 cx += (scrolldir == down) ? 3 : 2;
25570 183 no_move += (scrolldir == down) ? 3 : 2;
25571 183 }
25572 13695 }
25573 else
25574 {
25575 //4 frames after we've finished scrolling of being still
25576
4/4
✓ Branch 0 taken 2862 times.
✓ Branch 1 taken 93601 times.
✓ Branch 2 taken 1431 times.
✓ Branch 3 taken 1431 times.
96463 if(cx == 0 && !end_frames)
25577 {
25578 1431 cx += 4;
25579 1431 no_move += 4;
25580 1431 end_frames = true;
25581 1431 }
25582 }
25583 110158 }
25584
25585 //Move Hero and the scroll position
25586
2/2
✓ Branch 0 taken 21974 times.
✓ Branch 1 taken 243900 times.
265874 if(!no_move)
25587 {
25588
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 58333 times.
✓ Branch 2 taken 33345 times.
✓ Branch 3 taken 68722 times.
✓ Branch 4 taken 83500 times.
243900 switch(scrolldir)
25589 {
25590 case up:
25591 58333 sy -= step;
25592 58333 y += step;
25593 58333 break;
25594
25595 case down:
25596 33345 sy += step;
25597 33345 y -= step;
25598 33345 break;
25599
25600 case left:
25601 68722 sx -= step;
25602 68722 x += step;
25603 68722 break;
25604
25605 case right:
25606 83500 sx += step;
25607 83500 x -= step;
25608 83500 break;
25609 }
25610
25611 //bound Hero when me move him off the screen in the last couple of frames of scrolling
25612
2/2
✓ Branch 0 taken 5153 times.
✓ Branch 1 taken 238747 times.
243900 if(y > 160) y = 160;
25613
25614
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 240955 times.
243900 if(y < 0) y = 0;
25615
25616
2/2
✓ Branch 0 taken 4282 times.
✓ Branch 1 taken 239618 times.
243900 if(x > 240) x = 240;
25617
25618
2/2
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 238700 times.
243900 if(x < 0) x = 0;
25619
25620
4/4
✓ Branch 0 taken 243654 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 243644 times.
243900 if(ladderx > 0 || laddery > 0)
25621 {
25622 // If the ladder moves on both axes, the player can
25623 // gradually shift it by going back and forth
25624
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
25625 laddery = y.getInt();
25626 else
25627 256 ladderx = x.getInt();
25628 256 }
25629 243900 }
25630
25631 //Drawing
25632 265874 tx = sx;
25633 265874 ty = sy;
25634 265874 tx2 = sx;
25635 265874 ty2 = sy;
25636
25637
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 85412 times.
✓ Branch 2 taken 38497 times.
✓ Branch 3 taken 70304 times.
✓ Branch 4 taken 71661 times.
265874 switch(scrolldir)
25638 {
25639 case right:
25640 85412 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
25641 85412 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25642 85412 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
25643 85412 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25644 85412 tx -= 256;
25645 85412 break;
25646
25647 case down:
25648 38497 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25649 38497 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
25650 38497 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25651 38497 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
25652 38497 ty -= 176;
25653 38497 break;
25654
25655 case left:
25656 70304 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
25657 70304 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25658 70304 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
25659 70304 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25660 70304 tx2 -= 256;
25661 70304 break;
25662
25663 case up:
25664 71661 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25665 71661 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
25666 71661 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25667 71661 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
25668 71661 ty2 -= 176;
25669 71661 break;
25670 }
25671
25672 //FFScript.OnWaitdraw()
25673 265874 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25674
25675 265874 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
25676 265874 clear_bitmap(scrollbuf);
25677 265874 clear_bitmap(framebuf);
25678
25679
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 71661 times.
✓ Branch 2 taken 38497 times.
✓ Branch 3 taken 70304 times.
✓ Branch 4 taken 85412 times.
265874 switch(scrolldir)
25680 {
25681 case up:
25682
1/2
✓ Branch 0 taken 71661 times.
✗ Branch 1 not taken.
71661 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25683
25684
1/2
✓ Branch 0 taken 71661 times.
✗ Branch 1 not taken.
71661 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
25685
25686
1/2
✓ Branch 0 taken 71661 times.
✗ Branch 1 not taken.
71661 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25687
25688
1/2
✓ Branch 0 taken 71661 times.
✗ Branch 1 not taken.
71661 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
25689
25690 // Draw both screens' background layer primitives together, after both layers' combos.
25691 // Not ideal, but probably good enough for all realistic purposes.
25692
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71661 times.
✓ Branch 2 taken 71661 times.
✗ Branch 3 not taken.
71661 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25693
25694
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71661 times.
✓ Branch 2 taken 71661 times.
✗ Branch 3 not taken.
71661 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25695
25696 71661 putscr(scrollbuf, 0, 0, newscr);
25697 71661 putscr(scrollbuf, 0, 176, oldscr);
25698 71661 break;
25699
25700 case down:
25701
1/2
✓ Branch 0 taken 38497 times.
✗ Branch 1 not taken.
38497 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
25702
25703
1/2
✓ Branch 0 taken 38497 times.
✗ Branch 1 not taken.
38497 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25704
25705
1/2
✓ Branch 0 taken 38497 times.
✗ Branch 1 not taken.
38497 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
25706
25707
1/2
✓ Branch 0 taken 38497 times.
✗ Branch 1 not taken.
38497 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25708
25709
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38497 times.
✓ Branch 2 taken 38497 times.
✗ Branch 3 not taken.
38497 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25710
25711
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38497 times.
✓ Branch 2 taken 38497 times.
✗ Branch 3 not taken.
38497 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25712
25713 38497 putscr(scrollbuf, 0, 0, oldscr);
25714 38497 putscr(scrollbuf, 0, 176, newscr);
25715 38497 break;
25716
25717 case left:
25718
1/2
✓ Branch 0 taken 70304 times.
✗ Branch 1 not taken.
70304 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25719
25720
1/2
✓ Branch 0 taken 70304 times.
✗ Branch 1 not taken.
70304 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
25721
25722
1/2
✓ Branch 0 taken 70304 times.
✗ Branch 1 not taken.
70304 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25723
25724
1/2
✓ Branch 0 taken 70304 times.
✗ Branch 1 not taken.
70304 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
25725
25726
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70304 times.
✓ Branch 2 taken 70304 times.
✗ Branch 3 not taken.
70304 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25727
25728
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70304 times.
✓ Branch 2 taken 70304 times.
✗ Branch 3 not taken.
70304 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25729
25730 70304 putscr(scrollbuf, 0, 0, newscr);
25731 70304 putscr(scrollbuf, 256, 0, oldscr);
25732 70304 break;
25733
25734 case right:
25735
2/2
✓ Branch 0 taken 85280 times.
✓ Branch 1 taken 132 times.
85412 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
25736
25737
2/2
✓ Branch 0 taken 85346 times.
✓ Branch 1 taken 66 times.
85412 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25738
25739
1/2
✓ Branch 0 taken 85412 times.
✗ Branch 1 not taken.
85412 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
25740
25741
1/2
✓ Branch 0 taken 85412 times.
✗ Branch 1 not taken.
85412 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25742
25743
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 85280 times.
✓ Branch 2 taken 85214 times.
✓ Branch 3 taken 198 times.
85412 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25744
25745
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 85412 times.
✓ Branch 2 taken 85412 times.
✗ Branch 3 not taken.
85412 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25746
25747 85412 putscr(scrollbuf, 0, 0, oldscr);
25748 85412 putscr(scrollbuf, 256, 0, newscr);
25749 85412 break;
25750 }
25751
25752 265874 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
25753 265874 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
25754
25755 265874 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
25756 265874 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
25757
25758
2/2
✓ Branch 0 taken 265048 times.
✓ Branch 1 taken 826 times.
265874 if(get_bit(quest_rules, qr_FFCSCROLL))
25759 {
25760 826 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
25761 826 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
25762 826 }
25763
25764
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 265808 times.
265874 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
25765
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 265742 times.
265874 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
25766
25767 //push blocks
25768 265874 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
25769 265874 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
25770
2/2
✓ Branch 0 taken 265048 times.
✓ Branch 1 taken 826 times.
265874 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
25771 {
25772 826 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
25773 826 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
25774 826 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
25775 826 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
25776 826 }
25777
25778 265874 do_walkflags(framebuf, oldscr, tx2, ty2,3); //show walkflags if the cheat is on
25779 265874 do_walkflags(framebuf, newscr, tx, ty,2);
25780
25781 265874 do_effectflags(framebuf, oldscr, tx2, ty2,3); //show effectflags if the cheat is on
25782 265874 do_effectflags(framebuf, newscr, tx, ty,2);
25783
25784
25785 265874 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
25786 265874 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
25787 265874 herostep();
25788
25789
4/6
✓ Branch 0 taken 265874 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265874 times.
✓ Branch 4 taken 265874 times.
✓ Branch 5 taken 265874 times.
265874 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
25790 {
25791 531748 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
25792 531748 }
25793
25794
4/4
✓ Branch 0 taken 178055 times.
✓ Branch 1 taken 87819 times.
✓ Branch 2 taken 64397 times.
✓ Branch 3 taken 113658 times.
265874 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
25795 {
25796 152216 draw_under(framebuf); //draw the ladder or raft
25797 152216 decorations.draw2(framebuf, true);
25798 152216 draw(framebuf); //Hero
25799 152216 decorations.draw(framebuf, true);
25800 152216 }
25801
25802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265874 times.
265874 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
25803
25804 265874 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
25805 265874 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
25806
2/2
✓ Branch 0 taken 265048 times.
✓ Branch 1 taken 826 times.
265874 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25807 {
25808 826 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
25809 826 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
25810 826 }
25811 265874 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
25812 265874 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
25813 265874 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
25814
25815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265874 times.
265874 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
25816
25817 265874 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
25818 265874 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
25819
2/2
✓ Branch 0 taken 265048 times.
✓ Branch 1 taken 826 times.
265874 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25820 {
25821 826 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
25822 826 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
25823 826 }
25824 265874 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
25825 265874 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
25826 265874 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
25827
25828
25829
1/2
✓ Branch 0 taken 265874 times.
✗ Branch 1 not taken.
265874 if(msg_bg_display_buf->clip == 0)
25830 {
25831 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25832 }
25833
1/2
✓ Branch 0 taken 265874 times.
✗ Branch 1 not taken.
265874 if(msg_portrait_display_buf->clip == 0)
25834 {
25835 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25836 }
25837
1/2
✓ Branch 0 taken 265874 times.
✗ Branch 1 not taken.
265874 if(msg_txt_display_buf->clip == 0)
25838 {
25839 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25840 }
25841
25842
4/6
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 265048 times.
✓ Branch 2 taken 826 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 826 times.
265874 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
25843 {
25844 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
25845 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
25846 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
25847 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
25848 calc_darkroom_combos(true);
25849 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
25850 }
25851
25852
3/4
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 265048 times.
✓ Branch 2 taken 826 times.
✗ Branch 3 not taken.
265874 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
25853 {
25854 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25855 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25856 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25857 if(newscr->flags & fDARK)
25858 {
25859 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25860 {
25861 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25862 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25863 }
25864
25865 color_map = &trans_table2;
25866 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25867 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25868 else
25869 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25870 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25871 color_map = &trans_table;
25872 }
25873 if(oldscr->flags & fDARK)
25874 {
25875 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25876 {
25877 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25878 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25879 }
25880
25881 color_map = &trans_table2;
25882 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25883 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25884 else
25885 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25886 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25887 color_map = &trans_table;
25888 }
25889 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25890 }
25891 265874 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
25892
2/2
✓ Branch 0 taken 169859 times.
✓ Branch 1 taken 96015 times.
265874 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
25893 96015 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
25894
25895
3/4
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 265048 times.
✓ Branch 2 taken 826 times.
✗ Branch 3 not taken.
265874 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
25896 {
25897 826 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25898 826 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25899 826 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25900
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 if(newscr->flags & fDARK)
25901 {
25902 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25903 {
25904 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25905 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25906 }
25907
25908 color_map = &trans_table2;
25909 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25910 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25911 else
25912 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25913 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25914 color_map = &trans_table;
25915 }
25916
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 if(oldscr->flags & fDARK)
25917 {
25918 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25919 {
25920 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25921 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25922 }
25923
25924 color_map = &trans_table2;
25925 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25926 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25927 else
25928 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25929 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25930 color_map = &trans_table;
25931 }
25932 826 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25933 826 }
25934 265874 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
25935
25936 //end drawing
25937 265874 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25938 265874 advanceframe(true/*,true,false*/);
25939 265874 script_drawing_commands.Clear();
25940 265874 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25941 265874 actiontype lastaction = action;
25942 265874 action=scrolling; FFCore.setHeroAction(scrolling);
25943 265874 FFCore.runF6Engine();
25944 //FFCore.runF6EngineScrolling(newscr,oldscr,tx,ty,tx2,ty2,sx,sy,scrolldir);
25945 265874 action=lastaction; FFCore.setHeroAction(lastaction);
25946 265874 }//end main scrolling loop (2 spaces tab width makes me sad =( )
25947 3361 currdmap = olddmap;
25948
25949 3361 clear_bitmap(msg_txt_display_buf);
25950 3361 set_clip_state(msg_txt_display_buf, 1);
25951 3361 clear_bitmap(msg_bg_display_buf);
25952 3361 set_clip_state(msg_bg_display_buf, 1);
25953 3361 clear_bitmap(msg_portrait_display_buf);
25954 3361 set_clip_state(msg_portrait_display_buf, 1);
25955
25956 //Move hero to the other side of the screen if scrolling's not turned on
25957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if(get_bit(quest_rules, qr_NOSCROLL))
25958 {
25959 switch(scrolldir)
25960 {
25961 case up:
25962 y = 160;
25963 break;
25964
25965 case down:
25966 y = 0;
25967 break;
25968
25969 case left:
25970 x = 240;
25971 break;
25972
25973 case right:
25974 x = 0;
25975 break;
25976 }
25977 }
25978
25979
2/4
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3361 times.
✗ Branch 3 not taken.
3361 if((z > 0 || fakez > 0) && isSideViewHero())
25980 {
25981 y -= z;
25982 y -= fakez;
25983 z = 0;
25984 fakez = 0;
25985 }
25986
25987 3361 set_respawn_point(false);
25988 3361 trySideviewLadder();
25989 3361 warpx = -1;
25990 3361 warpy = -1;
25991
25992 3361 screenscrolling = false;
25993 3361 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
25994 3361 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25995 3361 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25996 3361 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25997 3361 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25998
25999
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 3323 times.
3361 if(destdmap != -1)
26000 {
26001 38 bool changedlevel = false;
26002 38 bool changeddmap = false;
26003
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 14 times.
38 if(olddmap != destdmap)
26004 {
26005 14 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26006 14 changeddmap = true;
26007 14 }
26008
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 1 times.
38 if(DMaps[olddmap].level != DMaps[destdmap].level)
26009 {
26010 1 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26011 1 changedlevel = true;
26012 1 }
26013 38 dlevel = DMaps[destdmap].level;
26014 38 currdmap = destdmap;
26015
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 14 times.
38 if(changeddmap)
26016 {
26017 14 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26018 14 }
26019
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 1 times.
38 if(changedlevel)
26020 {
26021 1 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26022 1 }
26023 38 }
26024
26025 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
26026 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
26027 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
26028 //direction. -DD
26029
26030
2/2
✓ Branch 0 taken 3331 times.
✓ Branch 1 taken 30 times.
3361 if(nowinwater)
26031 {
26032 30 SetSwim();
26033 30 hopclk = 0xFF;
26034 30 }
26035
26036 // NES behaviour: Fade to light after scrolling
26037 3361 lighting(false, false); // No, we don't need to set naturaldark...
26038
26039 3361 init_dmap();
26040 3361 putscr(scrollbuf,0,0,newscr);
26041 3361 putscrdoors(scrollbuf,0,0,newscr);
26042
26043 // Check for raft flags
26044
5/6
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 3260 times.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3260 times.
3361 if(action!=rafting && hopclk==0 && !toogam)
26045 {
26046
3/4
✓ Branch 0 taken 3257 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3257 times.
3260 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
26047 {
26048 3 sfx(tmpscr->secretsfx);
26049 3 action=rafting; FFCore.setHeroAction(rafting);
26050 3 raftclk=0;
26051 3 }
26052
26053 // Half a tile off?
26054
6/8
✓ Branch 0 taken 2492 times.
✓ Branch 1 taken 765 times.
✓ Branch 2 taken 925 times.
✓ Branch 3 taken 1567 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1690 times.
✓ Branch 6 taken 3257 times.
✗ Branch 7 not taken.
4947 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
26055 {
26056 sfx(tmpscr->secretsfx);
26057 action=rafting; FFCore.setHeroAction(rafting);
26058 raftclk=0;
26059 }
26060 3260 }
26061
26062 3361 opendoors=0;
26063 3361 markBmap(-1);
26064
26065
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 1870 times.
3361 if(isdungeon())
26066 {
26067
3/3
✓ Branch 0 taken 1057 times.
✓ Branch 1 taken 445 times.
✓ Branch 2 taken 368 times.
1870 switch(tmpscr->door[scrolldir^1])
26068 {
26069 case dOPEN:
26070 case dUNLOCKED:
26071 case dOPENBOSS:
26072 1057 dir = scrolldir;
26073
26074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1057 times.
1057 if(action!=rafting)
26075 1057 stepforward(diagonalMovement?11:12, false);
26076
26077 1057 break;
26078
26079 case dSHUTTER:
26080 case d1WAYSHUTTER:
26081 445 dir = scrolldir;
26082
26083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445 times.
445 if(action!=rafting)
26084 445 stepforward(diagonalMovement?21:24, false);
26085
26086 445 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
26087 445 opendoors=-4;
26088 445 sfx(WAV_DOOR);
26089 445 break;
26090
26091 default:
26092 368 dir = scrolldir;
26093
26094
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 329 times.
368 if(action!=rafting)
26095 329 stepforward(diagonalMovement?21:24, false);
26096 368 }
26097 1870 }
26098
26099
1/2
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
3361 if(action == scrolling)
26100 {
26101 action=none; FFCore.setHeroAction(none);
26102 }
26103
26104
2/4
✓ Branch 0 taken 3361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3361 times.
3361 if(action != attacking && action != sideswimattacking)
26105 {
26106 3361 charging = 0;
26107 3361 tapping = false;
26108 3361 }
26109
26110 3361 map_bkgsfx(true);
26111
26112
2/2
✓ Branch 0 taken 3346 times.
✓ Branch 1 taken 15 times.
3361 if(newscr->flags2&fSECRET)
26113 {
26114 15 sfx(newscr->secretsfx);
26115 15 }
26116
26117 3361 playLevelMusic();
26118
26119 3361 newscr_clk = frame;
26120 3361 activated_timed_warp=false;
26121 3361 loadside = scrolldir^1;
26122 3361 FFCore.init_combo_doscript();
26123 3361 eventlog_mapflags();
26124 3361 decorations.animate(); //continue to animate tall grass during scrolling
26125
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3348 times.
3361 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
26126 {
26127 //script_drawing_commands.Clear();
26128 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
26129 //ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
26130 13 }
26131 3361 }
26132
26133
26134
26135 // How much to reduce Hero's damage, taking into account various rings.
26136 3201 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
26137 {
26138
1/2
✓ Branch 0 taken 3201 times.
✗ Branch 1 not taken.
3201 if(dmg < 0) return dmg; //Don't reduce healing
26139
2/2
✓ Branch 0 taken 3197 times.
✓ Branch 1 taken 4 times.
3201 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
26140 {
26141 3197 int32_t divisor = 1;
26142 3197 float percentage = 1;
26143 3197 int32_t itemid = current_item_id(itype_ring);
26144 3197 bool usering = false;
26145
26146
4/4
✓ Branch 0 taken 2600 times.
✓ Branch 1 taken 597 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 2595 times.
3197 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26147 {
26148 2595 usering = true;
26149 2595 paymagiccost(itemid);
26150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2595 times.
2595 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26151 {
26152 percentage *= itemsbuf[itemid].power/100.0;
26153 }
26154 else
26155 {
26156 2595 divisor *= itemsbuf[itemid].power;
26157 }
26158 2595 }
26159
26160 /* Now for the Peril Ring */
26161 3197 itemid = current_item_id(itype_perilring);
26162
26163
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3197 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3197 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26164 {
26165 usering = true;
26166 paymagiccost(itemid);
26167 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26168 {
26169 percentage *= itemsbuf[itemid].power/100.0;
26170 }
26171 else
26172 {
26173 divisor *= itemsbuf[itemid].power;
26174 }
26175 }
26176
26177 // Ring divisor of 0 = no damage. -L
26178
4/6
✓ Branch 0 taken 2595 times.
✓ Branch 1 taken 602 times.
✓ Branch 2 taken 2595 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2595 times.
3197 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26179 return 0;
26180
26181
1/2
✓ Branch 0 taken 3197 times.
✗ Branch 1 not taken.
3197 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
26182
26183
1/2
✓ Branch 0 taken 3197 times.
✗ Branch 1 not taken.
3197 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
26184
1/2
✓ Branch 0 taken 3197 times.
✗ Branch 1 not taken.
3197 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26185
26186 }
26187 else
26188 {
26189 4 double divisor = 1;
26190 4 double percentage = 1;
26191 4 int32_t itemid = current_item_id(itype_ring);
26192 4 bool usering = false;
26193
26194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26195 {
26196 usering = true;
26197 paymagiccost(itemid);
26198 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26199 {
26200 double perc = itemsbuf[itemid].power/100.0;
26201 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26202 percentage *= perc;
26203 }
26204 else
26205 {
26206 if(itemsbuf[itemid].power < 0)
26207 divisor /= -(itemsbuf[itemid].power);
26208 else divisor *= itemsbuf[itemid].power;
26209 }
26210 }
26211
26212 /* Now for the Peril Ring */
26213 4 itemid = current_item_id(itype_perilring);
26214
26215
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26216 {
26217 usering = true;
26218 paymagiccost(itemid);
26219 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26220 {
26221 double perc = itemsbuf[itemid].power/100.0;
26222 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26223 percentage *= perc;
26224 }
26225 else
26226 {
26227 if(itemsbuf[itemid].power < 0)
26228 divisor /= -(itemsbuf[itemid].power);
26229 else divisor *= itemsbuf[itemid].power;
26230 }
26231 }
26232
26233 // Ring divisor of 0 = no damage. -L
26234
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26235 return 0;
26236
26237 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
26238
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26239 }
26240 3201 }
26241
26242 // Should swinging the hammer make the 'pound' sound?
26243 // Or is Hero just hitting air?
26244 bool HeroClass::sideviewhammerpound()
26245 {
26246 int32_t wx=0,wy=0;
26247
26248 switch(dir)
26249 {
26250 case up:
26251 wx=-1;
26252 wy=-15;
26253
26254 if(isSideViewHero()) wy+=8;
26255
26256 break;
26257
26258 case down:
26259 wx=8;
26260 wy=28;
26261
26262 if(isSideViewHero()) wy-=8;
26263
26264 break;
26265
26266 case left:
26267 wx=-8;
26268 wy=14;
26269
26270 if(isSideViewHero()) wy+=8;
26271
26272 break;
26273
26274 case right:
26275 wx=21;
26276 wy=14;
26277
26278 if(isSideViewHero()) wy+=8;
26279
26280 break;
26281 }
26282
26283 if(!isSideViewHero())
26284 {
26285 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
26286 }
26287
26288 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26289
26290 if(dir==left || dir==right)
26291 {
26292 wx+=16;
26293
26294 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26295 }
26296
26297 return false;
26298 }
26299
26300 /************************************/
26301 /******** More Items Code *********/
26302 /************************************/
26303
26304 // The following are only used for Hero damage. Damage is in quarter hearts.
26305 1707 int32_t enemy_dp(int32_t index)
26306 {
26307 1707 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
26308 }
26309
26310 1456 int32_t ewpn_dp(int32_t index)
26311 {
26312 1456 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
26313 }
26314
26315 17 int32_t lwpn_dp(int32_t index)
26316 {
26317 17 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
26318 }
26319
26320 33592052 bool checkbunny(int32_t itemid)
26321 {
26322
1/4
✓ Branch 0 taken 33592052 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33592052 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
26323 }
26324
26325 9756009 bool usesSwordJinx(int32_t itemid)
26326 {
26327 9756009 itemdata const& it = itemsbuf[itemid];
26328 9756009 bool ret = (it.family==itype_sword);
26329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9756009 times.
9756009 if(it.flags & ITEM_FLIP_JINX) return !ret;
26330 9756009 return ret;
26331 9756009 }
26332 8039479 bool checkitem_jinx(int32_t itemid)
26333 {
26334 8039479 itemdata const& it = itemsbuf[itemid];
26335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8039479 times.
8039479 if(it.flags & ITEM_JINX_IMMUNE) return true;
26336
2/2
✓ Branch 0 taken 2250664 times.
✓ Branch 1 taken 5788815 times.
8039479 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
26337 5788815 return HeroItemClk() == 0;
26338 8039479 }
26339
26340 119522 int32_t Bweapon(int32_t pos)
26341 {
26342
3/4
✓ Branch 0 taken 119522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✓ Branch 3 taken 119072 times.
119522 if(pos < 0 || current_subscreen_active == NULL)
26343 {
26344 450 return 0;
26345 }
26346
26347 119072 int32_t p=-1;
26348
26349
4/4
✓ Branch 0 taken 35027 times.
✓ Branch 1 taken 2939178 times.
✓ Branch 2 taken 35027 times.
✓ Branch 3 taken 2939178 times.
2974205 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
26350 {
26351
4/4
✓ Branch 0 taken 1948097 times.
✓ Branch 1 taken 991081 times.
✓ Branch 2 taken 1864052 times.
✓ Branch 3 taken 84045 times.
2939178 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
26352 {
26353 84045 p=i;
26354 84045 break;
26355 }
26356 2855133 }
26357
26358
2/2
✓ Branch 0 taken 84045 times.
✓ Branch 1 taken 35027 times.
119072 if(p==-1)
26359 {
26360 35027 return 0;
26361 }
26362
26363 84045 int32_t actualItem = current_subscreen_active->objects[p].d8;
26364 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
26365 84045 int32_t family = -1;
26366 84045 bool bow = false;
26367
26368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84045 times.
84045 if(actualItem)
26369 {
26370 bool select = false;
26371
26372 switch(itemsbuf[actualItem-1].family)
26373 {
26374 case itype_bomb:
26375 if((game->get_bombs() ||
26376 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26377 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
26378 current_item_power(itype_bombbag))
26379 {
26380 select=true;
26381 }
26382
26383 break;
26384
26385 case itype_bowandarrow:
26386 case itype_arrow:
26387 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
26388 {
26389 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26390 select=true;
26391 }
26392
26393 break;
26394
26395 case itype_letterpotion:
26396 /*if(current_item_id(itype_potion)>-1)
26397 {
26398 select=true;
26399 }
26400 else if(current_item_id(itype_letter)>-1)
26401 {
26402 select=true;
26403 }*/
26404 break;
26405
26406 case itype_sbomb:
26407 {
26408 int32_t bombbagid = current_item_id(itype_bombbag);
26409
26410 if((game->get_sbombs() ||
26411 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26412 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
26413 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26414 {
26415 select=true;
26416 }
26417
26418 break;
26419 }
26420
26421 case itype_sword:
26422 {
26423 if(!get_bit(quest_rules,qr_SELECTAWPN))
26424 break;
26425
26426 select=true;
26427 }
26428 break;
26429
26430 default:
26431 select=true;
26432 }
26433
26434 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
26435 {
26436 directItem = actualItem-1;
26437
26438 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
26439
26440 return actualItem-1+(bow?0xF000:0);
26441 }
26442 else return 0;
26443 }
26444
26445 84045 directItem = -1;
26446
26447
5/6
✓ Branch 0 taken 8437 times.
✓ Branch 1 taken 1010 times.
✓ Branch 2 taken 69963 times.
✓ Branch 3 taken 2794 times.
✓ Branch 4 taken 1841 times.
✗ Branch 5 not taken.
84045 switch(current_subscreen_active->objects[p].d1)
26448 {
26449 case itype_bomb:
26450 {
26451 8437 int32_t bombid = current_item_id(itype_bomb);
26452
26453
3/4
✓ Branch 0 taken 363 times.
✓ Branch 1 taken 8074 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 363 times.
8800 if((game->get_bombs() ||
26454 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26455
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 341 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
363 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
26456 363 current_item_power(itype_bombbag))
26457 {
26458 8074 family=itype_bomb;
26459 8074 }
26460
26461 8437 break;
26462 }
26463
26464 case itype_bowandarrow:
26465 case itype_arrow:
26466
3/4
✓ Branch 0 taken 2303 times.
✓ Branch 1 taken 491 times.
✓ Branch 2 taken 2303 times.
✗ Branch 3 not taken.
2794 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
26467 {
26468 2303 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26469 2303 family=itype_arrow;
26470 2303 }
26471
26472 2794 break;
26473
26474 case itype_letterpotion:
26475
2/2
✓ Branch 0 taken 1235 times.
✓ Branch 1 taken 606 times.
1841 if(current_item_id(itype_potion)>-1)
26476 {
26477 1235 family=itype_potion;
26478 1235 }
26479
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 186 times.
606 else if(current_item_id(itype_letter)>-1)
26480 {
26481 186 family=itype_letter;
26482 186 }
26483
26484 1841 break;
26485
26486 case itype_sbomb:
26487 {
26488 1010 int32_t bombbagid = current_item_id(itype_bombbag);
26489 1010 int32_t sbombid = current_item_id(itype_sbomb);
26490
26491
2/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 972 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1010 if((game->get_sbombs() ||
26492 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
26494
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26495 {
26496 972 family=itype_sbomb;
26497 972 }
26498
26499 1010 break;
26500 }
26501
26502 case itype_sword:
26503 {
26504 if(!get_bit(quest_rules,qr_SELECTAWPN))
26505 break;
26506
26507 family=itype_sword;
26508 }
26509 break;
26510
26511 default:
26512 69963 family=current_subscreen_active->objects[p].d1;
26513 69963 }
26514
26515
2/2
✓ Branch 0 taken 82733 times.
✓ Branch 1 taken 1312 times.
84045 if(family==-1)
26516 1312 return 0;
26517
26518
2/2
✓ Branch 0 taken 2814170 times.
✓ Branch 1 taken 2622 times.
2816792 for(int32_t j=0; j<MAXITEMS; j++)
26519 {
26520 // Find the item that matches this subscreen object.
26521
5/6
✓ Branch 0 taken 137381 times.
✓ Branch 1 taken 2676789 times.
✓ Branch 2 taken 80111 times.
✓ Branch 3 taken 57270 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80111 times.
2814170 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
26522 {
26523 80111 return j+(bow?0xF000:0);
26524 }
26525 2734059 }
26526
26527 2622 return 0;
26528 119522 }
26529
26530 int32_t BWeapon_to_Pos(int32_t bweapon)
26531 {
26532 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
26533 {
26534 if (Bweapon(i) == bweapon)
26535 {
26536 return i;
26537 }
26538 }
26539 return -1;
26540 }
26541
26542 void stopCaneOfByrna()
26543 {
26544 for(int32_t i=0; i<Lwpns.Count(); i++)
26545 {
26546 weapon *w = ((weapon*)Lwpns.spr(i));
26547 if(w->id==wCByrna)
26548 w->dead=1;
26549 }
26550 }
26551
26552 /* Crashes if used by ffscript.cpp, in case LINKITEMD
26553 void stopCaneOfByrna()
26554 {
26555 byte prnt_cane = -1;
26556 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
26557 prnt_cane = ew->parentitem;
26558 for(int32_t i=0; i<Lwpns.Count(); i++)
26559 {
26560 weapon *w = ((weapon*)Lwpns.spr(i));
26561
26562 if(w->id==wCByrna)
26563 {
26564 w->dead=1;
26565 }
26566 }
26567 if ( prnt_cane > -1 )
26568 {
26569 stop_sfx(itemsbuf[prnt_cane].usesound);
26570 }
26571 }
26572 */
26573 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
26574 2440355 void HeroClass::cleanupByrna()
26575 {
26576
1/2
✓ Branch 0 taken 2440355 times.
✗ Branch 1 not taken.
2440355 if ( last_cane_of_byrna_item_id > -1 )
26577 {
26578 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
26579 if ( !(Lwpns.idCount(wCByrna)) )
26580 {
26581 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
26582 last_cane_of_byrna_item_id = -1;
26583 }
26584 }
26585 2440355 }
26586
26587 // Used to find out if an item family is attached to one of the buttons currently pressed.
26588 754026 bool isWpnPressed(int32_t itype)
26589 {
26590 //0xFFF for subscreen overrides
26591 //Will crash on win10 without it! -Z
26592
4/4
✓ Branch 0 taken 26342 times.
✓ Branch 1 taken 727684 times.
✓ Branch 2 taken 14621 times.
✓ Branch 3 taken 11721 times.
754026 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
26593
4/4
✓ Branch 0 taken 378300 times.
✓ Branch 1 taken 364005 times.
✓ Branch 2 taken 101675 times.
✓ Branch 3 taken 276625 times.
742305 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
26594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 465680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
465680 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
26595
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 465680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
465680 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
26596 465680 return false;
26597 754026 }
26598
26599 2345672 int32_t getWpnPressed(int32_t itype)
26600 {
26601
4/4
✓ Branch 0 taken 11274 times.
✓ Branch 1 taken 2334398 times.
✓ Branch 2 taken 10828 times.
✓ Branch 3 taken 446 times.
2345672 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2345226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2345226 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2345226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2345226 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26604
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2345226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2345226 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26605
26606 2345226 return -1;
26607 2345672 }
26608
26609 2441884 int32_t getRocsPressed()
26610 {
26611 2441884 int32_t jumpid = current_item_id(itype_rocs,true,true);
26612
26613
2/2
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 2432965 times.
2441884 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
26614
26615
2/2
✓ Branch 0 taken 2432965 times.
✓ Branch 1 taken 8919 times.
2441884 if (jumpid != -1)
26616 {
26617 8919 itemdata const& itm = itemsbuf[jumpid];
26618
26619 8919 byte intbtn = byte(itm.misc2&0xFF);
26620
1/2
✓ Branch 0 taken 8919 times.
✗ Branch 1 not taken.
8919 if(getIntBtnInput(intbtn, false, true, false, false, true))
26621 return jumpid; //not pressed
26622 8919 }
26623
26624
4/4
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 2432965 times.
✓ Branch 2 taken 7992 times.
✓ Branch 3 taken 927 times.
2441884 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440957 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440957 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440957 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26628
26629 2440957 return -1;
26630 2441884 }
26631
26632 bool isItmPressed(int32_t itmid)
26633 {
26634 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
26635 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
26636 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
26637 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
26638 return false;
26639 }
26640
26641 void selectNextAWpn(int32_t type)
26642 {
26643 if(!get_bit(quest_rules,qr_SELECTAWPN))
26644 return;
26645
26646 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26647 Awpn = Bweapon(ret);
26648 directItemA = directItem;
26649 game->awpn = ret;
26650 }
26651
26652 2319 void selectNextBWpn(int32_t type)
26653 {
26654
2/4
✓ Branch 0 taken 2319 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2319 times.
2319 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26655 2319 Bwpn = Bweapon(ret);
26656 2319 directItemB = directItem;
26657 2319 game->bwpn = ret;
26658 2319 }
26659
26660 void selectNextXWpn(int32_t type)
26661 {
26662 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
26663 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26664 Xwpn = Bweapon(ret);
26665 directItemX = directItem;
26666 game->xwpn = ret;
26667 }
26668
26669 void selectNextYWpn(int32_t type)
26670 {
26671 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
26672 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
26673 Ywpn = Bweapon(ret);
26674 directItemY = directItem;
26675 game->ywpn = ret;
26676 }
26677
26678 18716 void verifyAWpn()
26679 {
26680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18716 times.
18716 if ( (game->forced_awpn != -1) )
26681 {
26682 return;
26683 }
26684
1/2
✓ Branch 0 taken 18716 times.
✗ Branch 1 not taken.
18716 if(!get_bit(quest_rules,qr_SELECTAWPN))
26685 {
26686 18716 Awpn = selectSword();
26687 18716 game->awpn = 0xFF;
26688 18716 }
26689 else
26690 {
26691 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
26692 Awpn = Bweapon(game->awpn);
26693 directItemA = directItem;
26694 }
26695 18716 }
26696
26697 17510 void verifyBWpn()
26698 {
26699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17510 times.
17510 if ( (game->forced_bwpn != -1) )
26700 {
26701 return;
26702 }
26703 17510 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
26704 17510 Bwpn = Bweapon(game->bwpn);
26705 17510 directItemB = directItem;
26706 17510 }
26707
26708 17510 void verifyXWpn()
26709 {
26710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17510 times.
17510 if ( (game->forced_xwpn != -1) )
26711 {
26712 return;
26713 }
26714
1/2
✓ Branch 0 taken 17510 times.
✗ Branch 1 not taken.
17510 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
26715 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
26716 17510 else game->xwpn = -1;
26717 17510 Xwpn = Bweapon(game->xwpn);
26718 17510 directItemX = directItem;
26719 17510 }
26720
26721 17510 void verifyYWpn()
26722 {
26723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17510 times.
17510 if ( (game->forced_ywpn != -1) )
26724 {
26725 return;
26726 }
26727
1/2
✓ Branch 0 taken 17510 times.
✗ Branch 1 not taken.
17510 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
26728 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
26729 17510 else game->ywpn = -1;
26730 17510 Ywpn = Bweapon(game->ywpn);
26731 17510 directItemY = directItem;
26732 17510 }
26733
26734 17510 void verifyBothWeapons()
26735 {
26736 17510 verifyAWpn();
26737 17510 verifyBWpn();
26738 17510 verifyXWpn();
26739 17510 verifyYWpn();
26740 17510 }
26741
26742 20765 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
26743 {
26744 //what will be returned when all else fails.
26745 //don't return the forbiddenpos... no matter what -DD
26746
26747 20765 int32_t failpos(0);
26748
26749
5/6
✓ Branch 0 taken 20435 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 20424 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20424 times.
20765 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
26750 341 failpos = 0xFF;
26751 20424 else failpos = startpos;
26752
26753 // verify startpos
26754
3/4
✓ Branch 0 taken 20765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 20422 times.
20765 if(startpos < 0 || startpos >= 0xFF)
26755 343 startpos = 0;
26756
26757
2/2
✓ Branch 0 taken 20615 times.
✓ Branch 1 taken 150 times.
20765 if(current_subscreen_active == NULL)
26758 150 return failpos;
26759
26760
4/4
✓ Branch 0 taken 3186 times.
✓ Branch 1 taken 17429 times.
✓ Branch 2 taken 414 times.
✓ Branch 3 taken 2772 times.
20615 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
26761 {
26762 17843 int32_t wpn = Bweapon(startpos);
26763
26764
5/8
✓ Branch 0 taken 17491 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 17491 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17491 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 17491 times.
17843 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
26765 {
26766 17491 return startpos;
26767 }
26768 352 }
26769
26770 3124 int32_t p=-1;
26771 3124 int32_t curpos = startpos;
26772 3124 int32_t firstValidPos=-1;
26773
26774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71438 times.
71438 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26775 {
26776
2/2
✓ Branch 0 taken 23904 times.
✓ Branch 1 taken 47534 times.
71438 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26777 {
26778
4/4
✓ Branch 0 taken 39611 times.
✓ Branch 1 taken 7923 times.
✓ Branch 2 taken 36487 times.
✓ Branch 3 taken 3124 times.
47534 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
26779 {
26780 3124 firstValidPos=i;
26781 3124 }
26782
26783
2/2
✓ Branch 0 taken 44410 times.
✓ Branch 1 taken 3124 times.
47534 if(current_subscreen_active->objects[i].d3==curpos)
26784 {
26785 3124 p=i;
26786 3124 break;
26787 }
26788 44410 }
26789 68314 }
26790
26791
1/2
✓ Branch 0 taken 3124 times.
✗ Branch 1 not taken.
3124 if(p == -1)
26792 {
26793 //can't find the current position
26794 // Switch to a valid weapon if there is one; otherwise,
26795 // the selector can simply disappear
26796 if(firstValidPos>=0)
26797 {
26798 return current_subscreen_active->objects[firstValidPos].d3;
26799 }
26800 //FAILURE
26801 else
26802 {
26803 return failpos;
26804 }
26805 }
26806
26807 //remember we've been here
26808 3124 set<int32_t> oldPositions;
26809
1/2
✓ Branch 0 taken 3124 times.
✗ Branch 1 not taken.
3124 oldPositions.insert(curpos);
26810
26811 //1. Perform any shifts required by the above
26812 //2. If that's not possible, go to position 1 and reset the b weapon.
26813 //2a. -if we arrive at a position we've already visited, give up and stay there
26814 //3. Get the weapon at the new slot
26815 //4. If it's not possible, go to step 1.
26816
26817 6495 for(;;)
26818 {
26819 //shift
26820
4/5
✓ Branch 0 taken 1691 times.
✓ Branch 1 taken 4752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 40 times.
6495 switch(type)
26821 {
26822 case SEL_LEFT:
26823 case SEL_VERIFY_LEFT:
26824 1691 curpos = current_subscreen_active->objects[p].d6;
26825 1691 break;
26826
26827 case SEL_RIGHT:
26828 case SEL_VERIFY_RIGHT:
26829 4752 curpos = current_subscreen_active->objects[p].d7;
26830 4752 break;
26831
26832 case SEL_DOWN:
26833 12 curpos = current_subscreen_active->objects[p].d5;
26834 12 break;
26835
26836 case SEL_UP:
26837 40 curpos = current_subscreen_active->objects[p].d4;
26838 40 break;
26839 }
26840
26841 //find our new position
26842 6495 p = -1;
26843
26844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161245 times.
161245 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26845 {
26846
2/2
✓ Branch 0 taken 51287 times.
✓ Branch 1 taken 109958 times.
161245 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26847 {
26848
2/2
✓ Branch 0 taken 103463 times.
✓ Branch 1 taken 6495 times.
109958 if(current_subscreen_active->objects[i].d3==curpos)
26849 {
26850 6495 p=i;
26851 6495 break;
26852 }
26853 103463 }
26854 154750 }
26855
26856
1/2
✓ Branch 0 taken 6495 times.
✗ Branch 1 not taken.
6495 if(p == -1)
26857 {
26858 //can't find the current position
26859 //FAILURE
26860 return failpos;
26861 }
26862
26863 //if we've already been here, give up
26864
4/6
✓ Branch 0 taken 6495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6495 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6159 times.
✓ Branch 5 taken 336 times.
6495 if(oldPositions.find(curpos) != oldPositions.end())
26865 {
26866 336 return failpos;
26867 }
26868
26869 //else, remember we've been here
26870
1/2
✓ Branch 0 taken 6159 times.
✗ Branch 1 not taken.
6159 oldPositions.insert(curpos);
26871
26872 //see if this weapon is acceptable
26873
6/10
✓ Branch 0 taken 6159 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2788 times.
✓ Branch 3 taken 3371 times.
✓ Branch 4 taken 2788 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2788 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2788 times.
6159 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
26874 2788 return curpos;
26875
26876 //keep going otherwise
26877 }
26878 20765 }
26879
26880 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
26881 18785 int32_t selectSword()
26882 {
26883 18785 auto ret = current_item_id(itype_sword);
26884
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 18523 times.
18785 if(ret == -1) return 0;
26885 18523 return ret;
26886 18785 }
26887
26888 // Adding code here for allowing hardcoding a button to a specific itemclass.
26889 int32_t selectItemclass(int32_t itemclass)
26890 {
26891 int32_t ret = current_item_id(itemclass);
26892
26893 if(ret == -1)
26894 ret = 0;
26895
26896 return ret;
26897 }
26898
26899 // Used for the 'Pickup Hearts' item pickup condition.
26900 40 bool canget(int32_t id)
26901 {
26902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
26903 }
26904
26905 23 void dospecialmoney(int32_t index)
26906 {
26907 23 int32_t tmp=currscr>=128?1:0;
26908 23 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
26909
26910
3/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
23 switch(tmpscr[tmp].room)
26911 {
26912 case rINFO: // pay for info
26913 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
26914 {
26915
26916
26917 if(!current_item_power(itype_wallet))
26918 {
26919 if (game->get_spendable_rupies() < abs(prices[priceindex]))
26920 return;
26921 int32_t tmpprice = -abs(prices[priceindex]);
26922 int32_t total = game->get_drupy()-tmpprice;
26923 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26924 game->set_drupy(game->get_drupy()-total);
26925 //game->change_drupy(-abs(prices[priceindex]));
26926 }
26927 if ( current_item_power(itype_wallet)>0 )
26928 {
26929 game->change_drupy(0);
26930 }
26931 }
26932 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
26933 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
26934 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
26935 clear_bitmap(pricesdisplaybuf);
26936 set_clip_state(pricesdisplaybuf, 1);
26937 items.del(0);
26938
26939 for(int32_t i=0; i<items.Count(); i++)
26940 ((item*)items.spr(i))->pickup=ipDUMMY;
26941
26942 // Prevent the prices from being displayed anymore
26943 for(int32_t i=0; i<3; i++)
26944 {
26945 prices[i] = 0;
26946 }
26947
26948 break;
26949
26950 case rMONEY: // secret money
26951 {
26952 10 ((item*)items.spr(0))->pickup = ipDUMMY;
26953
26954 10 prices[0] = tmpscr[tmp].catchall;
26955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!current_item_power(itype_wallet))
26956 10 game->change_drupy(prices[0]);
26957 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
26958
26959 10 putprices(false);
26960
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26961 10 break;
26962 }
26963
26964 case rGAMBLE: // gamble
26965 {
26966 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
26967
26968 unsigned si=(zc_oldrand()%24)*3;
26969
26970 for(int32_t i=0; i<3; i++)
26971 prices[i]=gambledat[si++];
26972
26973 game->set_drupy(game->get_drupy()+prices[priceindex]);
26974 putprices(true);
26975
26976 for(int32_t i=1; i<4; i++)
26977 ((item*)items.spr(i))->pickup=ipDUMMY;
26978 }
26979 break;
26980
26981 case rBOMBS:
26982 {
26983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26984 return;
26985
26986 3 int32_t price = -tmpscr[tmp].catchall;
26987 3 int32_t wmedal = current_item_id(itype_wealthmedal);
26988
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(wmedal >= 0)
26989 {
26990 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26991 price*=(itemsbuf[wmedal].misc1/100.0);
26992 else
26993 price+=itemsbuf[wmedal].misc1;
26994 }
26995
26996 3 int32_t total = game->get_drupy()-price;
26997 3 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26998 3 game->set_drupy(game->get_drupy()-total);
26999 //game->set_drupy(game->get_drupy()+price);
27000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27001 3 game->change_maxbombs(4);
27002 3 game->set_bombs(game->get_maxbombs());
27003 {
27004 3 int32_t div = zinit.bomb_ratio;
27005
27006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(div > 0)
27007 3 game->change_maxcounter(4/div, 6);
27008 }
27009
27010 //also give Hero an actual Bomb item
27011
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
27012 {
27013
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 763 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
768 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
27014 3 getitem(i, true, true);
27015 768 }
27016
27017 3 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27018 3 fadeclk=66;
27019 3 dismissmsg();
27020 3 clear_bitmap(pricesdisplaybuf);
27021 3 set_clip_state(pricesdisplaybuf, 1);
27022 // putscr(scrollbuf,0,0,tmpscr);
27023 3 verifyBothWeapons();
27024 3 break;
27025 }
27026
27027 case rARROWS:
27028 {
27029 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27030 return;
27031
27032 int32_t price = -tmpscr[tmp].catchall;
27033 int32_t wmedal = current_item_id(itype_wealthmedal);
27034 if(wmedal >= 0)
27035 {
27036 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
27037 price*=(itemsbuf[wmedal].misc1/100.0);
27038 else
27039 price+=itemsbuf[wmedal].misc1;
27040 }
27041
27042 int32_t total = game->get_drupy()-price;
27043 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27044 game->set_drupy(game->get_drupy()-total);
27045
27046 //game->set_drupy(game->get_drupy()+price);
27047 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27048 game->change_maxarrows(10);
27049 game->set_arrows(game->get_maxarrows());
27050 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27051 fadeclk=66;
27052 dismissmsg();
27053 clear_bitmap(pricesdisplaybuf);
27054 set_clip_state(pricesdisplaybuf, 1);
27055 // putscr(scrollbuf,0,0,tmpscr);
27056 verifyBothWeapons();
27057 break;
27058 }
27059
27060 case rSWINDLE:
27061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(items.spr(index)->id==iRupy)
27062 {
27063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27064 return;
27065 10 int32_t tmpprice = -tmpscr[tmp].catchall;
27066 10 int32_t total = game->get_drupy()-tmpprice;
27067 10 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27068 10 game->set_drupy(game->get_drupy()-total);
27069 10 }
27070 else
27071 {
27072 if(game->get_maxlife()<=game->get_hp_per_heart())
27073 return;
27074
27075 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
27076 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
27077 }
27078
27079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27080 10 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
27081 10 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
27082 10 fadeclk=66;
27083 10 dismissmsg();
27084 10 clear_bitmap(pricesdisplaybuf);
27085 10 set_clip_state(pricesdisplaybuf, 1);
27086 // putscr(scrollbuf,0,0,tmpscr);
27087 10 break;
27088 }
27089 23 }
27090
27091 4304 void getitem(int32_t id, bool nosound, bool doRunPassive)
27092 {
27093
1/2
✓ Branch 0 taken 4304 times.
✗ Branch 1 not taken.
4304 if(id<0)
27094 {
27095 return;
27096 }
27097
27098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4304 times.
4304 if (replay_is_active())
27099
1/2
✓ Branch 0 taken 4304 times.
✗ Branch 1 not taken.
4304 replay_step_comment(fmt::format("getitem {}", item_string[id]));
27100
27101
2/2
✓ Branch 0 taken 4301 times.
✓ Branch 1 taken 3 times.
4304 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
27102 {
27103 3 int32_t nextitem = -1;
27104 3 do
27105 {
27106 3 nextitem = -1;
27107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
27108 // Item upgrade routine.
27109 {
27110
27111 for(int32_t i=0; i<MAXITEMS; i++)
27112 {
27113 // Find the item which is as close to this item's fam_type as possible.
27114 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
27115 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27116 {
27117 nextitem = i;
27118 }
27119 }
27120
27121 if(nextitem>-1)
27122 {
27123 id = nextitem;
27124 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27125 break; //no looping
27126 }
27127 }
27128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 } while(nextitem > -1);
27129 3 }
27130
27131 4304 itemdata const& idat = itemsbuf[id&0xFF];
27132 // if(idat.family!=0xFF) //1.92 compat... that already should be changed to 'itype_misc'? Blehg, hate this! -Em
27133 {
27134
4/4
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 3996 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 277 times.
4304 if(idat.flags & ITEM_GAMEDATA && idat.family != itype_triforcepiece)
27135 {
27136 // Fix boomerang sounds.
27137 277 int32_t itemid = current_item_id(idat.family);
27138
27139
4/6
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
277 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_nayruslove
27140
3/6
✓ Branch 0 taken 159 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✗ Branch 5 not taken.
159 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
27141 163 && sfx_allocated(itemsbuf[itemid].usesound)
27142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
163 && idat.usesound != itemsbuf[itemid].usesound)
27143 {
27144 stop_sfx(itemsbuf[itemid].usesound);
27145 cont_sfx(idat.usesound);
27146 }
27147
27148 277 int32_t curitm = current_item_id(idat.family);
27149
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
277 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
27150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
277 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
27151 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
27152 {
27153 277 game->set_item(id,true);
27154 277 passiveitem_script(id, doRunPassive);
27155 277 }
27156
27157
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 244 times.
277 if(!(idat.flags & ITEM_KEEPOLD))
27158 {
27159
3/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 242 times.
244 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
27160 {
27161 2 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
27162 2 }
27163 244 }
27164
27165 // NES consistency: replace all flying boomerangs with the current boomerang.
27166
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 11 times.
277 if(idat.family==itype_brang)
27167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 for(int32_t i=0; i<Lwpns.Count(); i++)
27168 {
27169 weapon *w = ((weapon*)Lwpns.spr(i));
27170
27171 if(w->id==wBrang)
27172 {
27173 w->LOADGFX(idat.wpn);
27174 }
27175 11 }
27176 277 }
27177
27178
2/2
✓ Branch 0 taken 591 times.
✓ Branch 1 taken 3713 times.
4304 if(idat.count!=-1)
27179 {
27180
2/2
✓ Branch 0 taken 3652 times.
✓ Branch 1 taken 61 times.
3713 if(idat.setmax)
27181 {
27182 // Bomb bags are a special case; they may be set not to increase super bombs
27183
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
61 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
27184 {
27185 int32_t max = game->get_maxbombs();
27186
27187 if(max<idat.max) max=idat.max;
27188
27189 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
27190 }
27191 else
27192 {
27193 61 int32_t max = game->get_maxcounter(idat.count);
27194
27195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(max<idat.max) max=idat.max;
27196
27197
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 7 times.
61 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
27198 }
27199 61 }
27200
27201 // Amount is an uint16_t, but the range is -9999 to 16383
27202 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
27203
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3683 times.
3713 if(idat.amount&0x3FFF)
27204 {
27205
2/2
✓ Branch 0 taken 2477 times.
✓ Branch 1 taken 1206 times.
3683 if(idat.amount&0x8000)
27206 4954 game->set_dcounter(
27207
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2476 times.
2477 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27208 else
27209 {
27210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1206 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
27211 game->set_counter(0, idat.count);
27212 else
27213 // This is too confusing to try and change...
27214
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1206 times.
✓ Branch 2 taken 573 times.
✓ Branch 3 taken 633 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 573 times.
1206 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
27215 }
27216 3683 }
27217 3713 }
27218 }
27219
27220
3/4
✓ Branch 0 taken 4304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 4276 times.
4304 if(idat.playsound&&!nosound)
27221 {
27222 4276 sfx(idat.playsound);
27223 4276 }
27224
27225 //add lower-level items
27226
2/2
✓ Branch 0 taken 4289 times.
✓ Branch 1 taken 15 times.
4304 if(idat.flags&ITEM_GAINOLD)
27227 {
27228
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 15 times.
29 for(int32_t i=idat.fam_type-1; i>0; i--)
27229 {
27230 14 int32_t potid = getItemID(itemsbuf, idat.family, i);
27231
27232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(potid != -1)
27233 {
27234 14 game->set_item(potid, true);
27235 14 }
27236 14 }
27237 15 }
27238
27239
10/14
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3834 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 184 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 26 times.
✓ Branch 9 taken 24 times.
✓ Branch 10 taken 19 times.
✓ Branch 11 taken 163 times.
✓ Branch 12 taken 18 times.
✗ Branch 13 not taken.
4304 switch(idat.family)
27240 {
27241 case itype_itmbundle:
27242 {
27243 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27244 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27245 bool pscript = (idat.flags & ITEM_FLAG1);
27246 for(auto q = 0; q < 10; ++q)
27247 {
27248 if(unsigned(ids[q]) >= MAXITEMS) continue;
27249 if(pscript)
27250 collectitem_script(ids[q]);
27251 getitem(ids[q], true, true);
27252 }
27253 }
27254 break;
27255
27256 case itype_progressive_itm:
27257 {
27258 int32_t newid = get_progressive_item(idat);
27259 if(newid > -1)
27260 getitem(newid, nosound, true);
27261 }
27262 break;
27263
27264 case itype_bottlefill:
27265 {
27266 if(idat.misc1)
27267 {
27268 game->fillBottle(idat.misc1);
27269 }
27270 }
27271 break;
27272
27273 case itype_clock:
27274 {
27275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 184 times.
184 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27276 break;
27277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 184 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
184 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
27278 break;
27279 184 setClock(watch=true);
27280
27281
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 184 times.
94392 for(int32_t i=0; i<eMAXGUYS; i++)
27282 94208 clock_zoras[i]=0;
27283
27284 184 clockclk=itemsbuf[id&0xFF].misc1;
27285 184 sfx(idat.usesound);
27286 }
27287 184 break;
27288
27289 case itype_lkey:
27290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
27291 28 break;
27292
27293 case itype_ring:
27294 case itype_magicring:
27295
5/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
7 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27296 {
27297 7 ringcolor(false);
27298 7 }
27299 7 break;
27300
27301 case itype_whispring:
27302 {
27303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(idat.flags & ITEM_FLAG1)
27304 {
27305
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
27306
27307
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
27308 1 }
27309
27310
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(idat.power==0)
27311 {
27312 setSwordClk(0);
27313 setItemClk(0);
27314 }
27315
27316 1 break;
27317 }
27318
27319
27320 case itype_map:
27321 26 game->lvlitems[dlevel]|=liMAP;
27322 26 break;
27323
27324 case itype_compass:
27325 24 game->lvlitems[dlevel]|=liCOMPASS;
27326 24 break;
27327
27328 case itype_bosskey:
27329 19 game->lvlitems[dlevel]|=liBOSSKEY;
27330 19 break;
27331
27332 case itype_fairy:
27333
27334
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 101 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
163 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
27335
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
163 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
27336 163 break;
27337
27338 case itype_heartpiece:
27339 18 game->change_HCpieces(1);
27340
27341
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4 times.
18 if(game->get_HCpieces()<game->get_hcp_per_hc())
27342 14 break;
27343
27344 4 game->set_HCpieces(0);
27345
27346 4 getitem(heart_container_id());
27347 4 break;
27348
27349 case itype_killem:
27350 {
27351 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27352 break;
27353 kill_em_all();
27354 sfx(idat.usesound);
27355 }
27356 break;
27357 }
27358
27359 4304 flushItemCache();
27360 4304 update_subscreens();
27361 4304 load_Sitems(&QMisc);
27362 4304 verifyBothWeapons();
27363 4304 }
27364
27365 void takeitem(int32_t id)
27366 {
27367 game->set_item(id, false);
27368 itemdata const& idat = itemsbuf[id];
27369
27370 /* Lower the counters! */
27371 if(idat.count!=-1)
27372 {
27373 if(idat.setmax)
27374 {
27375 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
27376 }
27377
27378 if(idat.amount&0x3FFF)
27379 {
27380 if(idat.amount&0x8000)
27381 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27382 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27383 }
27384 }
27385
27386 switch(itemsbuf[id&0xFF].family)
27387 {
27388 // NES consistency: replace all flying boomerangs with the current boomerang.
27389 case itype_brang:
27390 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
27391 {
27392 weapon *w = ((weapon*)Lwpns.spr(i));
27393
27394 if(w->id==wBrang)
27395 {
27396 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
27397 }
27398 }
27399
27400 break;
27401
27402 case itype_itmbundle:
27403 {
27404 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27405 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27406 for(auto q = 0; q < 10; ++q)
27407 {
27408 if(unsigned(ids[q]) >= MAXITEMS) continue;
27409 takeitem(ids[q]);
27410 }
27411 }
27412 break;
27413
27414 case itype_progressive_itm:
27415 {
27416 int32_t newid = get_progressive_item(idat, true);
27417 if(newid > -1)
27418 takeitem(newid);
27419 }
27420 break;
27421
27422 case itype_heartpiece:
27423 if(game->get_maxlife()>game->get_hp_per_heart())
27424 {
27425 if(game->get_HCpieces()==0)
27426 {
27427 game->set_HCpieces(game->get_hcp_per_hc());
27428 takeitem(iHeartC);
27429 }
27430
27431 game->change_HCpieces(-1);
27432 }
27433 break;
27434
27435 case itype_map:
27436 game->lvlitems[dlevel]&=~liMAP;
27437 break;
27438
27439 case itype_compass:
27440 game->lvlitems[dlevel]&=~liCOMPASS;
27441 break;
27442
27443 case itype_bosskey:
27444 game->lvlitems[dlevel]&=~liBOSSKEY;
27445 break;
27446
27447 case itype_lkey:
27448 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
27449 break;
27450
27451 case itype_ring:
27452 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27453 {
27454 ringcolor(false);
27455 }
27456 break;
27457 }
27458 }
27459
27460 // Attempt to pick up an item. (-1 = check items touching Hero.)
27461 2439236 void HeroClass::checkitems(int32_t index)
27462 {
27463 2439236 int32_t tmp=currscr>=128?1:0;
27464
27465
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 2438507 times.
2439236 if(index==-1)
27466 {
27467
2/2
✓ Branch 0 taken 558322 times.
✓ Branch 1 taken 2438507 times.
2996829 for(auto ind = items.Count()-1; ind >= 0; --ind)
27468 {
27469 558322 item* itm = (item*)items.spr(ind);
27470
1/2
✓ Branch 0 taken 558322 times.
✗ Branch 1 not taken.
558322 if(itm->get_forcegrab())
27471 {
27472 checkitems(ind);
27473 }
27474 558322 }
27475
2/2
✓ Branch 0 taken 9349 times.
✓ Branch 1 taken 2429158 times.
2438507 if(diagonalMovement)
27476 {
27477 9349 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
27478 9349 }
27479 2429158 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
27480 2438507 }
27481
27482
2/2
✓ Branch 0 taken 21900 times.
✓ Branch 1 taken 2417336 times.
2439236 if(index==-1)
27483 2417336 return;
27484
27485 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
27486 // return;
27487 21900 item* ptr = (item*)items.spr(index);
27488 21900 int32_t pickup = ptr->pickup;
27489 21900 int8_t exstate = ptr->pickupexstate;
27490 21900 int32_t PriceIndex = ptr->PriceIndex;
27491 21900 int32_t id2 = ptr->id;
27492 21900 int32_t holdid = ptr->id;
27493 21900 int32_t pstr = ptr->pstring;
27494 21900 int32_t pstr_flags = ptr->pickup_string_flags;
27495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21900 times.
21900 if(ptr->fallclk > 0) return; //Don't pick up a falling item
27496
27497
1/2
✓ Branch 0 taken 21900 times.
✗ Branch 1 not taken.
21900 if(itemsbuf[id2].family == itype_progressive_itm)
27498 {
27499 int32_t newid = get_progressive_item(itemsbuf[id2]);
27500 if(newid > -1)
27501 {
27502 id2 = newid;
27503 holdid = newid;
27504 pstr = itemsbuf[newid].pstring;
27505 pstr_flags = itemsbuf[newid].pickup_string_flags;
27506 }
27507 }
27508
27509
2/2
✓ Branch 0 taken 21732 times.
✓ Branch 1 taken 168 times.
21900 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
27510
27511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21900 times.
21900 if(bottledummy) //Dummy bullshit!
27512 {
27513 if(!game->canFillBottle())
27514 return;
27515 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27516 {
27517 if(!current_item_power(itype_wallet))
27518 {
27519 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27520 int32_t tmpprice = -abs(prices[PriceIndex]);
27521 //game->change_drupy(-abs(prices[priceindex]));
27522 int32_t total = game->get_drupy()-tmpprice;
27523 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27524 game->set_drupy(game->get_drupy()-total);
27525 }
27526 else //infinite wallet
27527 {
27528 game->change_drupy(0);
27529 }
27530 }
27531 boughtsomething=true;
27532 //make the other shop items untouchable after
27533 //you buy something
27534 int32_t count = 0;
27535
27536 for(int32_t i=0; i<3; i++)
27537 {
27538 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
27539 {
27540 ++count;
27541 }
27542 }
27543
27544 for(int32_t i=0; i<items.Count(); i++)
27545 {
27546 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27547 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27548 }
27549
27550 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
27551 id2 = find_bottle_for_slot(slot);
27552 ptr->id = id2;
27553 pstr = 0;
27554 pickup |= ipHOLDUP;
27555 }
27556 else
27557 {
27558 21900 std::vector<int32_t> &ev = FFCore.eventData;
27559 21900 ev.clear();
27560 21900 ev.push_back(id2*10000);
27561 21900 ev.push_back(pickup*10000);
27562 21900 ev.push_back(pstr*10000);
27563 21900 ev.push_back(pstr_flags*10000);
27564 21900 ev.push_back(0);
27565 21900 ev.push_back(ptr->getUID());
27566 21900 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
27567 21900 ev.push_back(0);
27568
27569 21900 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
27570 21900 bool nullify = ev[4] != 0;
27571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21900 times.
21900 if(nullify) return;
27572 21900 id2 = ev[0]/10000;
27573 21900 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
27574 21900 pstr = ev[2] / 10000;
27575 21900 pstr_flags = ev[3] / 10000;
27576
27577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21900 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
27578 return; //No picking these up unless you have a bottle to fill!
27579
27580
5/6
✓ Branch 0 taken 21104 times.
✓ Branch 1 taken 796 times.
✓ Branch 2 taken 18493 times.
✓ Branch 3 taken 2611 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18493 times.
21900 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
27581
2/2
✓ Branch 0 taken 18443 times.
✓ Branch 1 taken 50 times.
18493 if(ptr->id!=iFairyMoving)
27582 // wait for it to stop flashing, doesn't check for other items yet
27583 18443 return;
27584
27585
2/2
✓ Branch 0 taken 3442 times.
✓ Branch 1 taken 15 times.
3457 if(pickup&ipENEMY) // item was being carried by enemy
27586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if(more_carried_items()<=1) // 1 includes this own item.
27587 15 hasitem &= ~2;
27588
27589
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 3246 times.
3457 if(pickup&ipDUMMY) // dummy item (usually a rupee)
27590 {
27591
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 23 times.
211 if(pickup&ipMONEY)
27592 23 dospecialmoney(index);
27593
27594 211 return;
27595 }
27596
27597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3246 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3246 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
27598 return;
27599
27600 3246 int32_t nextitem = -1;
27601 3246 do
27602 {
27603 3246 nextitem = -1;
27604
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3236 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 7 times.
3246 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
27605 // Item upgrade routine.
27606 {
27607
27608
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7 times.
1799 for(int32_t i=0; i<MAXITEMS; i++)
27609 {
27610 // Find the item which is as close to this item's fam_type as possible.
27611
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1776 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
1792 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
27612
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
16 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27613 {
27614 7 nextitem = i;
27615 7 }
27616 1792 }
27617
27618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nextitem>-1)
27619 {
27620 7 id2 = nextitem;
27621
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
27622 {
27623 pstr = itemsbuf[id2].pstring;
27624 pstr_flags = itemsbuf[id2].pickup_string_flags;
27625 }
27626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27627 7 break; //no looping
27628 }
27629 }
27630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3239 times.
3239 } while(nextitem > -1);
27631
27632
2/2
✓ Branch 0 taken 3078 times.
✓ Branch 1 taken 168 times.
3246 if(pickup&ipCHECK) // check restrictions
27633
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 106 times.
168 switch(tmpscr[tmp].room)
27634 {
27635 case rSP_ITEM: // special item
27636
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1 times.
40 if(!canget(id2)) // These ones always need the Hearts Required check
27637 1 return;
27638
27639 39 break;
27640
27641 case rP_SHOP: // potion shop
27642
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 13 times.
106 if(msg_active)
27643 93 return;
27644 [[fallthrough]];
27645 case rSHOP: // shop
27646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27647 {
27648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!current_item_power(itype_wallet))
27649 {
27650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27651 35 int32_t tmpprice = -abs(prices[PriceIndex]);
27652 //game->change_drupy(-abs(prices[priceindex]));
27653 35 int32_t total = game->get_drupy()-tmpprice;
27654 35 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27655 35 game->set_drupy(game->get_drupy()-total);
27656 35 }
27657 else //infinite wallet
27658 {
27659 game->change_drupy(0);
27660 }
27661 35 }
27662 35 boughtsomething=true;
27663 //make the other shop items untouchable after
27664 //you buy something
27665 35 int32_t count = 0;
27666
27667
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 35 times.
140 for(int32_t i=0; i<3; i++)
27668 {
27669
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 96 times.
105 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
27670 {
27671 96 ++count;
27672 96 }
27673 105 }
27674
27675
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 35 times.
166 for(int32_t i=0; i<items.Count(); i++)
27676 {
27677
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 61 times.
131 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27678 61 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27679 131 }
27680
27681 35 break;
27682 74 }
27683
27684
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 2840 times.
3152 if(pickup&ipONETIME) // set mITEM for one-time-only items
27685 {
27686 312 setmapflag(mITEM);
27687
27688 //Okay so having old source files is a godsend. You wanna know why?
27689 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
27690 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
27691 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
27692 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
27693 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
27694
27695 /*
27696 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
27697 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
27698
27699 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
27700 // What is etc?! We need to check for every valid state here. ~Gleeok
27701 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
27702 {
27703 // Most older quests need one-time-pickups to not remove special items, etc.
27704 if(tmpscr->room==rGRUMBLE)
27705 {
27706 setmapflag(mSPECIALITEM);
27707 }
27708 }
27709 */
27710 312 }
27711
2/2
✓ Branch 0 taken 2699 times.
✓ Branch 1 taken 141 times.
2840 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
27712
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 13 times.
141 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27713
27714
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3152 if(exstate > -1 && exstate < 32)
27715 {
27716 setxmapflag(1<<exstate);
27717 }
27718
27719
1/2
✓ Branch 0 taken 3152 times.
✗ Branch 1 not taken.
3152 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
27720 {
27721 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
27722 hidden_entrance(0, true, false, -5);
27723 }
27724
27725 3152 collectitem_script(id2);
27726 3152 getitem(id2, false, true);
27727 }
27728
27729
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 2908 times.
3152 if(pickup&ipHOLDUP)
27730 {
27731 244 attackclk=0;
27732 244 reset_swordcharge();
27733
27734
3/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 242 times.
244 if(action!=swimming && !IsSideSwim())
27735 242 reset_hookshot();
27736
27737
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 84 times.
244 if(msg_onscreen)
27738 {
27739 84 dismissmsg();
27740 84 }
27741
27742 244 clear_bitmap(pricesdisplaybuf);
27743
27744
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
244 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
27745 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
27746 {
27747 244 fadeclk=66;
27748 244 }
27749
27750
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
244 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
27751 {
27752 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
27753
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 240 times.
242 if(action==swimming)
27754 {
27755 2 action=waterhold1; FFCore.setHeroAction(waterhold1);
27756 2 }
27757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
240 else if(IsSideSwim())
27758 {
27759 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
27760 }
27761 else
27762 {
27763 240 action=landhold1; FFCore.setHeroAction(landhold1);
27764 }
27765
27766
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 88 times.
242 if(ptr->twohand)
27767 {
27768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(action==waterhold1)
27769 {
27770 action=waterhold2; FFCore.setHeroAction(waterhold2);
27771 }
27772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 else if(action==sidewaterhold1)
27773 {
27774 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
27775 }
27776 else
27777 {
27778 88 action=landhold2; FFCore.setHeroAction(landhold2);
27779 }
27780 88 }
27781
27782 242 holdclk=130;
27783
27784 //restart music
27785
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 30 times.
242 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
27786 30 music_stop();
27787
27788 242 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
27789 242 freeze_guys=true;
27790 //show the info string
27791
27792
27793 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
27794
27795 242 int32_t shop_pstr = 0;
27796
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 45 times.
242 if (PriceIndex > -1)
27797 {
27798
2/3
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
45 switch(tmpscr[tmp].room)
27799 {
27800 case rSHOP:
27801 22 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
27802 22 break;
27803 case rBOTTLESHOP:
27804 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
27805 break;
27806 }
27807 45 }
27808
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 242 times.
242 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27809 {
27810 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
27811 {
27812 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27813 }
27814 else pstr = 0;
27815 if(shop_pstr)
27816 {
27817 donewmsg(shop_pstr);
27818 enqueued_str = pstr;
27819 }
27820 else if(pstr)
27821 {
27822 donewmsg(pstr);
27823 }
27824 }
27825
27826 242 }
27827
27828
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 213 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
244 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
27829 {
27830 213 sfx(tmpscr[0].holdupsfx);
27831 213 }
27832
27833 244 ptr->set_forcegrab(false);
27834 244 items.del(index);
27835
27836
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 244 times.
280 for(int32_t i=0; i<Lwpns.Count(); i++)
27837 {
27838 36 weapon *w = (weapon*)Lwpns.spr(i);
27839
27840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(w->dragging==index)
27841 {
27842 w->dragging=-1;
27843 }
27844
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 else if(w->dragging>index)
27845 {
27846 w->dragging-=1;
27847 }
27848 36 }
27849
27850 // clear up shop stuff
27851
4/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 158 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 43 times.
244 if((isdungeon()==0)&&(index!=0))
27852 {
27853
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 34 times.
43 if(boughtsomething)
27854 {
27855 34 fadeclk=66;
27856
27857
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
27858 {
27859 34 items.del(0);
27860
27861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 for(int32_t i=0; i<Lwpns.Count(); i++)
27862 {
27863 weapon *w = (weapon*)Lwpns.spr(i);
27864
27865 if(w->dragging==0)
27866 {
27867 w->dragging=-1;
27868 }
27869 else if(w->dragging>0)
27870 {
27871 w->dragging-=1;
27872 }
27873 }
27874 34 }
27875 34 }
27876
27877
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(msg_onscreen)
27878 {
27879 dismissmsg();
27880 }
27881
27882 43 clear_bitmap(pricesdisplaybuf);
27883 43 set_clip_state(pricesdisplaybuf, 1);
27884 43 }
27885
27886 // items.del(index);
27887 244 }
27888 else
27889 {
27890 2908 ptr->set_forcegrab(false);
27891 2908 items.del(index);
27892
27893
2/2
✓ Branch 0 taken 2080 times.
✓ Branch 1 taken 2908 times.
4988 for(int32_t i=0; i<Lwpns.Count(); i++)
27894 {
27895 2080 weapon *w = (weapon*)Lwpns.spr(i);
27896
27897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2080 times.
2080 if(w->dragging==index)
27898 {
27899 w->dragging=-1;
27900 }
27901
1/2
✓ Branch 0 taken 2080 times.
✗ Branch 1 not taken.
2080 else if(w->dragging>index)
27902 {
27903 w->dragging-=1;
27904 }
27905 2080 }
27906
27907
2/2
✓ Branch 0 taken 2907 times.
✓ Branch 1 taken 1 times.
2908 if(msg_onscreen)
27908 {
27909 1 dismissmsg();
27910 1 }
27911
27912 //general item pickup message
27913 //show the info string
27914 //non-held
27915 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
27916
3/6
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 2840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2908 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
27917
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2908 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2908 times.
2908 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27918 {
27919 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
27920 {
27921 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27922 }
27923 else pstr = 0;
27924 if(shop_pstr)
27925 {
27926 donewmsg(shop_pstr);
27927 enqueued_str = pstr;
27928 }
27929 else if(pstr)
27930 {
27931 donewmsg(pstr);
27932 }
27933 }
27934
27935
27936 2908 clear_bitmap(pricesdisplaybuf);
27937 2908 set_clip_state(pricesdisplaybuf, 1);
27938 }
27939
27940
2/2
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 34 times.
3152 if(itemsbuf[id2].family==itype_triforcepiece)
27941 {
27942
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 3 times.
34 if(itemsbuf[id2].misc2>0) //Small TF Piece
27943 {
27944 31 getTriforce(id2);
27945 31 }
27946 else
27947 {
27948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (ptr->linked_parent == eeGANON) game->lvlitems[dlevel]|=liBOSS;
27949 3 getBigTri(id2);
27950 }
27951 34 }
27952 2439236 }
27953
27954 101 void HeroClass::StartRefill(int32_t refillWhat)
27955 {
27956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(!refilling)
27957 {
27958 101 refillclk=21;
27959 101 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27960 101 sfx(WAV_REFILL,128,true);
27961 101 refilling=refillWhat;
27962
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(FFCore.quest_format[vZelda] < 0x255)
27963 {
27964 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
27965 //I attempted to change this check to a quest rule, but here's the issue: this affects
27966 //triforces and potions as well, not just fairy flags. This means that having a compat rule
27967 //would result in a rule that is checked by default for every tileset or quest made before
27968 //2.55, one in a place most people won't check. That means that if they were to go to use
27969 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
27970 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
27971 //"go through the compat rules and turn them all off", so this remains a version check instead
27972 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
27973 101 Start250Refill(refillWhat);
27974 101 }
27975 else //use 2.55+ behavior
27976 {
27977 if(refill_why>=0) // Item index
27978 {
27979 if(itemsbuf[refill_why].family==itype_potion)
27980 {
27981 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27982 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27983 }
27984 else if(itemsbuf[refill_why].family==itype_triforcepiece)
27985 {
27986 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27987 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27988 }
27989 }
27990 else if(refill_why==REFILL_FAIRY)
27991 {
27992 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
27993 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
27994 }
27995 }
27996 101 }
27997 101 }
27998
27999 101 void HeroClass::Start250Refill(int32_t refillWhat)
28000 {
28001
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(!refilling)
28002 {
28003 refillclk=21;
28004 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
28005 sfx(WAV_REFILL,128,true);
28006 refilling=refillWhat;
28007
28008 if(refill_why>=0) // Item index
28009 {
28010 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
28011 {
28012 swordclk=0;
28013 verifyAWpn();
28014 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28015 }
28016
28017 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
28018 {
28019 swordclk=0;
28020 verifyAWpn();
28021 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28022 }
28023 }
28024 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
28025 {
28026 swordclk=0;
28027 verifyAWpn();
28028 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28029 }
28030 }
28031 101 }
28032
28033 83280 bool HeroClass::refill()
28034 {
28035
4/4
✓ Branch 0 taken 12199 times.
✓ Branch 1 taken 71081 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 11563 times.
83280 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
28036 {
28037 71717 return false;
28038 }
28039
28040 11563 ++refillclk;
28041 11563 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
28042 11563 int32_t refill_heart_stop=game->get_maxlife();
28043 11563 int32_t refill_magic_stop=game->get_maxmagic();
28044
28045
4/4
✓ Branch 0 taken 6100 times.
✓ Branch 1 taken 5463 times.
✓ Branch 2 taken 2075 times.
✓ Branch 3 taken 4025 times.
11563 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
28046 {
28047
2/6
✓ Branch 0 taken 4025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4025 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4025 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
28048
2/6
✓ Branch 0 taken 4025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4025 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4025 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
28049 4025 }
28050
28051
2/2
✓ Branch 0 taken 10711 times.
✓ Branch 1 taken 852 times.
11563 if(refillclk%speed == 0)
28052 {
28053 // game->life&=0xFFC;
28054
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
852 switch(refill_what)
28055 {
28056 case REFILL_LIFE:
28057
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 364 times.
384 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28058
28059
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 331 times.
384 if(game->get_life()>=refill_heart_stop)
28060 {
28061 53 game->set_life(refill_heart_stop);
28062 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28063
2/2
✓ Branch 0 taken 13568 times.
✓ Branch 1 taken 53 times.
13621 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28064 {
28065
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 13515 times.
13568 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28066
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13514 times.
13515 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28067 13514 stop_sfx(q);
28068 13514 }
28069 53 sfx(QMisc.miscsfx[sfxREFILL]);
28070 53 refilling=REFILL_NONE;
28071 53 return false;
28072 }
28073
28074 331 break;
28075
28076 case REFILL_MAGIC:
28077 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28078
28079 if(game->get_magic()>=refill_magic_stop)
28080 {
28081 game->set_magic(refill_magic_stop);
28082 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28083 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28084 {
28085 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28086 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28087 stop_sfx(q);
28088 }
28089 sfx(QMisc.miscsfx[sfxREFILL]);
28090 refilling=REFILL_NONE;
28091 return false;
28092 }
28093
28094 break;
28095
28096 case REFILL_ALL:
28097
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 438 times.
468 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28098
1/2
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
468 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28099
28100
3/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 420 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
468 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
28101 {
28102 48 game->set_life(refill_heart_stop);
28103 48 game->set_magic(refill_magic_stop);
28104 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28105
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 48 times.
12336 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28106 {
28107
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12240 times.
12288 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28108
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 12223 times.
12240 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28109 12223 stop_sfx(q);
28110 12223 }
28111 48 sfx(QMisc.miscsfx[sfxREFILL]);
28112 48 refilling=REFILL_NONE;
28113 48 return false;
28114 }
28115
28116 420 break;
28117 }
28118 751 }
28119
28120 11462 return true;
28121 83280 }
28122
28123 31 void HeroClass::getTriforce(int32_t id2)
28124 {
28125
28126 PALETTE flash_pal;
28127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
28128
28129
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
7967 for(int32_t i=0; i<256; i++)
28130 {
28131
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 6144 times.
7936 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
28132 7936 }
28133
28134
28135
28136 //get rid off all sprites but Hero
28137 31 guys.clear();
28138 31 items.clear();
28139 31 Ewpns.clear();
28140 31 Lwpns.clear();
28141 31 Sitems.clear();
28142 31 chainlinks.clear();
28143
28144 //decorations.clear();
28145
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(!COOLSCROLL)
28146 {
28147 17 show_subscreen_items=false;
28148 17 }
28149
28150 31 sfx(itemsbuf[id2].playsound);
28151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
28152
28153 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
28154
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
28155 {
28156 uint8_t playwav = itemsbuf[id2].misc3;
28157 //zprint2("playwav is: %d\n", playwav);
28158 sfx(playwav);
28159
28160 }
28161
28162 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
28163 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
28164 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
28165 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
28166 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
28167 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
28168 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
28169
28170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
28171 {
28172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(itemsbuf[id2].misc1)
28173 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
28174 else
28175 31 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
28176 31 }
28177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28178 {
28179 31 game->lvlitems[dlevel]|=liTRIFORCE;
28180 31 }
28181
28182 31 int32_t f=0;
28183 31 int32_t x2=0;
28184 31 int32_t curtain_x=0;
28185 31 int32_t c=0;
28186 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
28187 {
28188 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
28189 {
28190 //clear the item script stack for a new script
28191 ri = &(itemCollectScriptData[id2]);
28192 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
28193 ri->Clear();
28194 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
28195 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
28196 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
28197 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
28198 {
28199 item_collect_doscript[id2] = 1;
28200 itemscriptInitialised[id2] = 0;
28201 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
28202 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28203 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
28204 }
28205 else if (!id2 && !item_collect_doscript[id2]) //item 0
28206 {
28207 item_collect_doscript[id2] = 1;
28208 itemscriptInitialised[id2] = 0;
28209 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
28210 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28211 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
28212 }
28213 }
28214 }
28215 */
28216 31 do
28217 {
28218
28219
28220
1/2
✓ Branch 0 taken 16901 times.
✗ Branch 1 not taken.
16901 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
28221 {
28222 if ( itemsbuf[id2].script )
28223 {
28224 if ( !item_doscript[id2] )
28225 {
28226 ri = &(itemScriptData[id2]);
28227 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
28228 ri->Clear();
28229 item_doscript[id2] = 1;
28230 itemscriptInitialised[id2] = 0;
28231 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
28232 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
28233 }
28234 else
28235 {
28236 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
28237 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
28238 }
28239 }
28240 }
28241 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
28242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16901 times.
16901 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
28243 {
28244 return;
28245 }
28246
2/2
✓ Branch 0 taken 16870 times.
✓ Branch 1 taken 31 times.
16901 if(f==40)
28247 {
28248 31 actiontype oldaction = action;
28249 31 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
28250 31 action=oldaction; // have to reset this flag
28251 31 FFCore.setHeroAction(oldaction);
28252 31 }
28253
28254
28255
4/4
✓ Branch 0 taken 15661 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 14173 times.
✓ Branch 3 taken 1488 times.
16901 if(f>=40 && f<88)
28256 {
28257
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 1152 times.
1488 if(get_bit(quest_rules,qr_FADE))
28258 {
28259 //int32_t flashbit = ;
28260
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 84 times.
336 if((f&(((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)) ? 6 : 3))==0)
28261 {
28262 84 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
28263 84 refreshpal=true;
28264 84 }
28265
28266
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 84 times.
336 if((f&3)==2)
28267 {
28268 84 loadpalset(0,0);
28269 84 loadpalset(1,1);
28270 84 loadpalset(5,5);
28271
28272
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28273 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
28274 84 }
28275 336 }
28276 else
28277 {
28278
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 144 times.
1152 if((f&((get_bit(quest_rules,qr_EPILEPSY)) ? 10 : 7))==0)
28279 {
28280
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 144 times.
576 for(int32_t cs2=2; cs2<5; cs2++)
28281 {
28282
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 432 times.
6912 for(int32_t i=1; i<16; i++)
28283 {
28284 6480 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
28285 6480 }
28286 432 }
28287
28288 144 refreshpal=true;
28289 144 }
28290
28291
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 144 times.
1152 if((f&7)==4)
28292 {
28293
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28294 else loadlvlpal(0xB);
28295
28296 144 loadpalset(5,5);
28297 144 }
28298 }
28299 1488 }
28300
28301
28302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16901 times.
16901 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28303 {
28304
2/2
✓ Branch 0 taken 16870 times.
✓ Branch 1 taken 31 times.
16901 if(f==refill_frame)
28305 {
28306 31 refill_what=REFILL_ALL;
28307 31 refill_why=id2;
28308 31 StartRefill(REFILL_ALL);
28309 31 refill();
28310 31 }
28311
28312
2/2
✓ Branch 0 taken 14849 times.
✓ Branch 1 taken 2052 times.
16901 if(f==(refill_frame+1))
28313 {
28314
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 2021 times.
2052 if(refill())
28315 {
28316 2021 --f;
28317 2021 }
28318 2052 }
28319 16901 }
28320
28321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16901 times.
16901 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
28322 {
28323
4/4
✓ Branch 0 taken 8432 times.
✓ Branch 1 taken 8469 times.
✓ Branch 2 taken 5952 times.
✓ Branch 3 taken 2480 times.
16901 if(f>=208 && f<288)
28324 {
28325 2480 ++x2;
28326
28327
3/3
✓ Branch 0 taken 992 times.
✓ Branch 1 taken 992 times.
✓ Branch 2 taken 496 times.
2480 switch(++c)
28328 {
28329 case 5:
28330 496 c=0;
28331 [[fallthrough]];
28332 case 0:
28333 case 2:
28334 case 3:
28335 1488 ++x2;
28336 1488 break;
28337 }
28338 2480 }
28339
28340 16901 do_dcounters();
28341
28342
2/2
✓ Branch 0 taken 5952 times.
✓ Branch 1 taken 10949 times.
16901 if(f<288)
28343 {
28344 10949 curtain_x=x2&0xF8;
28345 10949 draw_screen_clip_rect_x1=curtain_x;
28346 10949 draw_screen_clip_rect_x2=255-curtain_x;
28347 10949 draw_screen_clip_rect_y1=0;
28348 10949 draw_screen_clip_rect_y2=223;
28349 //draw_screen(tmpscr);
28350 10949 }
28351 16901 }
28352
28353 16901 draw_screen(tmpscr);
28354 //this causes bugs
28355 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
28356 //so this is not necessary -DD
28357 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
28358
28359 //Run Triforce Script
28360 16901 advanceframe(true);
28361 16901 ++f;
28362
2/2
✓ Branch 0 taken 16870 times.
✓ Branch 1 taken 31 times.
33802 }
28363 while
28364 (
28365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16901 times.
16901 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
28366
4/6
✓ Branch 0 taken 2263 times.
✓ Branch 1 taken 14638 times.
✓ Branch 2 taken 2263 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2263 times.
16901 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
28367
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2263 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2263 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2125 times.
✓ Branch 7 taken 138 times.
4526 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
28368 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
28369 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
28370 // value doesn't matter.
28371
2/4
✓ Branch 0 taken 2125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2263 times.
2263 || (replay_is_active() && f < 480) )
28372 ); // 800 may not be just right, but it works
28373
28374 31 action=none; FFCore.setHeroAction(none);
28375 31 holdclk=0;
28376 31 draw_screen_clip_rect_x1=0;
28377 31 draw_screen_clip_rect_x2=255;
28378 31 draw_screen_clip_rect_y1=0;
28379 31 draw_screen_clip_rect_y2=223;
28380 31 show_subscreen_items=true;
28381
28382 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
28383 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
28384
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
31 if(itemsbuf[id2].flags & ITEM_FLAG1 && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
28385 {
28386 32 sdir=dir;
28387 32 dowarp(1,0); //side warp
28388 32 }
28389 else
28390 {
28391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
28392 }
28393 31 }
28394
28395 111 void red_shift()
28396 {
28397 111 int32_t tnum=176;
28398
28399 // set up the new palette
28400
2/2
✓ Branch 0 taken 3552 times.
✓ Branch 1 taken 111 times.
3663 for(int32_t i=CSET(2); i < CSET(4); i++)
28401 {
28402 3552 int32_t r = (i-CSET(2)) << 1;
28403 3552 RAMpal[i+tnum].r = r;
28404 3552 RAMpal[i+tnum].g = r >> 3;
28405 3552 RAMpal[i+tnum].b = r >> 4;
28406 3552 }
28407
28408 // color scale the game screen
28409
2/2
✓ Branch 0 taken 18648 times.
✓ Branch 1 taken 111 times.
18759 for(int32_t y=0; y<168; y++)
28410 {
28411
2/2
✓ Branch 0 taken 4773888 times.
✓ Branch 1 taken 18648 times.
4792536 for(int32_t x=0; x<256; x++)
28412 {
28413 4773888 int32_t c = framebuf->line[y+playing_field_offset][x];
28414
2/2
✓ Branch 0 taken 2583169 times.
✓ Branch 1 taken 2190719 times.
4773888 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28415
1/2
✓ Branch 0 taken 4773888 times.
✗ Branch 1 not taken.
4773888 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
28416 4773888 }
28417 18648 }
28418
28419 111 refreshpal = true;
28420 111 }
28421
28422
28423
28424 void setup_red_screen_old()
28425 {
28426 clear_bitmap(framebuf);
28427 rectfill(scrollbuf, 0, 0, 255, 167, 0);
28428
28429 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
28430
28431 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
28432
28433 putscr(scrollbuf, 0, 0, tmpscr);
28434 putscrdoors(scrollbuf,0,0,tmpscr);
28435 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28436 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
28437
28438 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
28439
28440 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
28441 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
28442 {
28443 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
28444 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
28445 }
28446
28447 if(!(msg_bg_display_buf->clip))
28448 {
28449 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28450 }
28451
28452 if(!(msg_portrait_display_buf->clip))
28453 {
28454 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28455 }
28456
28457 if(!(msg_txt_display_buf->clip))
28458 {
28459 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28460 }
28461
28462 if(!(pricesdisplaybuf->clip))
28463 {
28464 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
28465 }
28466
28467 //red shift
28468 // color scale the game screen
28469 for(int32_t y=0; y<168; y++)
28470 {
28471 for(int32_t x=0; x<256; x++)
28472 {
28473 int32_t c = framebuf->line[y+playing_field_offset][x];
28474 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28475 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
28476 }
28477 }
28478
28479 // Hero->draw(framebuf);
28480 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
28481
28482 clear_bitmap(framebuf);
28483
28484 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
28485 && tmpscr->layermap[3]==0
28486 && tmpscr->layermap[4]==0
28487 && tmpscr->layermap[5]==0
28488 && !overheadcombos(tmpscr)))
28489 {
28490 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
28491
28492 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
28493 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
28494 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
28495 {
28496 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
28497 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
28498 }
28499 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
28500 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
28501
28502 //do an AND masked blit for messages on top of layers
28503 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
28504 {
28505 BITMAP* subbmp = create_bitmap_ex(8,256,168);
28506 clear_bitmap(subbmp);
28507 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
28508 {
28509 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
28510 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
28511 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
28512 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
28513 }
28514 for(int32_t y=0; y<168; y++)
28515 {
28516 for(int32_t x=0; x<256; x++)
28517 {
28518 int32_t c1 = framebuf->line[y+playing_field_offset][x];
28519 int32_t c2 = subbmp->line[y][x];
28520 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
28521
28522 if(c1 && c3)
28523 {
28524 framebuf->line[y+playing_field_offset][x] = c3;
28525 }
28526 else if(c1 && c2)
28527 {
28528 framebuf->line[y+playing_field_offset][x] = c2;
28529 }
28530 }
28531 }
28532 destroy_bitmap(subbmp);
28533 }
28534
28535 //red shift
28536 // color scale the game screen
28537 for(int32_t y=0; y<168; y++)
28538 {
28539 for(int32_t x=0; x<256; x++)
28540 {
28541 int32_t c = framebuf->line[y+playing_field_offset][x];
28542 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28543 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
28544 }
28545 }
28546 }
28547
28548 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
28549
28550 // set up the new palette
28551 for(int32_t i=CSET(2); i < CSET(4); i++)
28552 {
28553 int32_t r = (i-CSET(2)) << 1;
28554 RAMpal[i].r = r;
28555 RAMpal[i].g = r >> 3;
28556 RAMpal[i].b = r >> 4;
28557 }
28558
28559 refreshpal = true;
28560 }
28561
28562
28563
28564 35 void slide_in_color(int32_t color)
28565 {
28566
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 35 times.
210 for(int32_t i=1; i<16; i+=3)
28567 {
28568 175 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
28569 175 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
28570 175 RAMpal[CSET(2)+i] = NESpal(color);
28571 175 }
28572
28573 35 refreshpal=true;
28574 35 }
28575
28576
28577 8 void HeroClass::heroDeathAnimation()
28578 {
28579 8 int32_t f=0;
28580 8 int32_t deathclk=0,deathfrm=0;
28581
28582 8 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
28583
28584 8 kill_sfx(); //call before the onDeath script.
28585
28586 //do
28587 //{
28588
28589 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28590 // FFCore.Waitframe();
28591 //}while(player_doscript);
28592 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28593 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
28594
28595 //Playing=false;
28596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!debug_enabled)
28597 {
28598 8 Paused=false;
28599 8 }
28600
28601 /*
28602 game->set_deaths(zc_min(game->get_deaths()+1,999));
28603 dir=down;
28604 music_stop();
28605
28606 attackclk=hclk=superman=0;
28607 scriptcoldet = 1;
28608
28609 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28610
28611
28612
28613 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28614 quakeclk=wavy=0;
28615
28616 //in original Z1, Hero marker vanishes at death.
28617 //code in subscr.cpp, put_passive_subscr checks the following value.
28618 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28619 //Also, subscreen is static after death in Z1.
28620 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28621 QMisc.colors.hero_dot = 255;
28622 //doesn't work
28623 //scrollbuf is tampered with by draw_screen()
28624 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28625 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28626 clear_bitmap(subscrbmp);
28627 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
28628 QMisc.colors.hero_dot = tmp_hero_dot;
28629 */
28630 8 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28631 8 clear_bitmap(subscrbmp);
28632 //get rid off all sprites but Hero
28633 8 guys.clear();
28634 8 items.clear();
28635 8 Ewpns.clear();
28636 8 Lwpns.clear();
28637 8 Sitems.clear();
28638 8 chainlinks.clear();
28639 8 decorations.clear();
28640 8 Playing = false;
28641
28642
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
28643 8 dir=down;
28644 8 music_stop();
28645
28646 8 attackclk=hclk=superman=0;
28647 8 scriptcoldet = 1;
28648
28649
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 8 times.
264 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28650
28651
28652
28653 8 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28654 8 quakeclk=wavy=0;
28655
28656 //in original Z1, Hero marker vanishes at death.
28657 //code in subscr.cpp, put_passive_subscr checks the following value.
28658 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28659 //Also, subscreen is static after death in Z1.
28660 8 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28661 8 QMisc.colors.hero_dot = 255;
28662 //doesn't work
28663 //scrollbuf is tampered with by draw_screen()
28664 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28665
28666 8 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
28667 //Don't forget passive subscreen scripts!
28668
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
28669 {
28670 script_drawing_commands.Clear(); //We only want draws from this script
28671 if(DMaps[currdmap].passive_sub_script != 0)
28672 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28673 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
28674 {
28675 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28676 passive_subscreen_waitdraw = false;
28677 }
28678 BITMAP* tmp = framebuf;
28679 framebuf = subscrbmp; //Hack; force draws to subscrbmp
28680 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
28681 framebuf = tmp;
28682 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
28683 }
28684 8 QMisc.colors.hero_dot = tmp_hero_dot;
28685 8 bool clearedit = false;
28686 8 do
28687 {
28688 //if ( player_doscript )
28689 //{
28690 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_WIN, SCRIPT_PLAYER_WIN);
28691 //if ( f ) --f;
28692 // load_control_state(); //goto adv;
28693 //}
28694 //else
28695 //{
28696 // if ( !clearedit )
28697 // {
28698
28699
28700 // clearedit = true;
28701
28702 // }
28703 //}
28704 //else Playing = false;
28705
2/2
✓ Branch 0 taken 2032 times.
✓ Branch 1 taken 792 times.
2824 if(f<254)
28706 {
28707
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 264 times.
2032 if(f<=32)
28708 {
28709 264 hclk=(32-f);
28710 264 }
28711
28712
4/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 928 times.
✓ Branch 3 taken 608 times.
2032 if(f>=62 && f<138)
28713 {
28714
5/5
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 32 times.
608 switch((f-62)%20)
28715 {
28716 case 0:
28717 32 dir=right;
28718 32 break;
28719
28720 case 5:
28721 32 dir=up;
28722 32 break;
28723
28724 case 10:
28725 32 dir=left;
28726 32 break;
28727
28728 case 15:
28729 32 dir=down;
28730 32 break;
28731 }
28732
28733 608 herostep();
28734 608 }
28735
28736
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1552 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 112 times.
2032 if(f>=194 && f<208)
28737 {
28738
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 8 times.
112 if(f==194)
28739 {
28740 8 action=dying;
28741 8 FFCore.setHeroAction(dying);
28742 8 }
28743
28744 112 extend = 0;
28745 112 cs = wpnsbuf[spr_death].csets&15;
28746 112 tile = wpnsbuf[spr_death].tile;
28747
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
28748 {
28749 tile += deathfrm;
28750 f = 206;
28751 if(++deathclk >= wpnsbuf[spr_death].speed)
28752 {
28753 deathclk=0;
28754 if(++deathfrm >= wpnsbuf[spr_death].frames)
28755 {
28756 f = 208;
28757 deathfrm = 0;
28758 }
28759 }
28760 }
28761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 else if(BSZ)
28762 {
28763 tile += (f-194)/3;
28764 }
28765
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 32 times.
112 else if(f>=204)
28766 {
28767 32 ++tile;
28768 32 }
28769 112 }
28770
28771
2/2
✓ Branch 0 taken 2024 times.
✓ Branch 1 taken 8 times.
2032 if(f==208)
28772 {
28773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if ( dontdraw < 2 ) { dontdraw = 1; }
28774 8 }
28775
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 1778 times.
2032 if(get_bit(quest_rules,qr_FADE))
28776 {
28777
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 84 times.
254 if(f < 170)
28778 {
28779
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 60 times.
170 if(f<60)
28780 {
28781 60 draw_screen(tmpscr);
28782 //reuse our static subscreen
28783 60 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28784 60 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28785 60 }
28786
28787
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 1 times.
170 if(f==60)
28788 {
28789 1 red_shift();
28790 1 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28791 1 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28792 1 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28793
28794
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t q=0; q<PAL_SIZE; q++)
28795 {
28796 256 trans_table2.data[0][q] = q;
28797 256 trans_table2.data[q][q] = q;
28798 256 }
28799 1 }
28800
28801
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
170 if(f>=60 && f<=169)
28802 {
28803 110 draw_screen(tmpscr);
28804 //reuse our static subscreen
28805 110 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28806 110 red_shift();
28807
28808 110 }
28809
28810
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
170 if(f>=139 && f<=169)//fade from red to black
28811 {
28812 31 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
28813 31 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28814 31 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28815 31 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28816
28817
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
7967 for(int32_t q=0; q<PAL_SIZE; q++)
28818 {
28819 7936 trans_table2.data[0][q] = q;
28820 7936 trans_table2.data[q][q] = q;
28821 7936 }
28822
28823 31 refreshpal=true;
28824 31 }
28825 170 }
28826 else //f>=170
28827 {
28828
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1 times.
84 if(f==170)//make Hero grayish
28829 {
28830 1 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
28831
28832
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 for(int32_t i=CSET(6); i < CSET(7); i++)
28833 {
28834 16 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
28835 16 RAMpal[i] = _RGB(g,g,g);
28836 16 }
28837
28838 1 refreshpal = true;
28839 1 }
28840
28841 //draw only hero. otherwise black layers might cover him.
28842 84 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28843 84 draw(framebuf);
28844 84 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28845 }
28846 254 }
28847 else //!qr_FADE
28848 {
28849
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==58)
28850 {
28851
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 7 times.
679 for(int32_t i = 0; i < 96; i++)
28852 672 tmpscr->cset[i] = 3;
28853
28854
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t j=0; j<6; j++)
28855
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 40 times.
44 if(tmpscr->layermap[j]>0)
28856
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
28857 194 tmpscr2[j].cset[i] = 3;
28858 7 }
28859
28860
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==59)
28861 {
28862
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 7 times.
567 for(int32_t i = 96; i < 176; i++)
28863 560 tmpscr->cset[i] = 3;
28864
28865
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t j=0; j<6; j++)
28866
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 40 times.
44 if(tmpscr->layermap[j]>0)
28867
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
28868 162 tmpscr2[j].cset[i] = 3;
28869 7 }
28870
28871
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==60)
28872 {
28873
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 7 times.
1239 for(int32_t i=0; i<176; i++)
28874 {
28875 1232 tmpscr->cset[i] = 2;
28876 1232 }
28877
28878
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t j=0; j<6; j++)
28879
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 40 times.
44 if(tmpscr->layermap[j]>0)
28880
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
28881 354 tmpscr2[j].cset[i] = 2;
28882
28883
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7 times.
42 for(int32_t i=1; i<16; i+=3)
28884 {
28885 35 RAMpal[CSET(2)+i] = NESpal(0x17);
28886 35 RAMpal[CSET(2)+i+1] = NESpal(0x16);
28887 35 RAMpal[CSET(2)+i+2] = NESpal(0x26);
28888 35 }
28889
28890 7 refreshpal=true;
28891 7 }
28892
28893
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==139)
28894 7 slide_in_color(0x06);
28895
28896
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==149)
28897 7 slide_in_color(0x07);
28898
28899
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==159)
28900 7 slide_in_color(0x0F);
28901
28902
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==169)
28903 {
28904 7 slide_in_color(0x0F);
28905 7 slide_in_color(0x0F);
28906 7 }
28907
28908
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 if(f==170)
28909 {
28910
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7 times.
42 for(int32_t i=1; i<16; i+=3)
28911 {
28912 35 RAMpal[CSET(6)+i] = NESpal(0x10);
28913 35 RAMpal[CSET(6)+i+1] = NESpal(0x30);
28914 35 RAMpal[CSET(6)+i+2] = NESpal(0x00);
28915 35 refreshpal = true;
28916 35 }
28917 7 }
28918
28919
2/2
✓ Branch 0 taken 1183 times.
✓ Branch 1 taken 595 times.
1778 if(f < 169)
28920 {
28921 1183 draw_screen(tmpscr);
28922 //reuse our static subscreen
28923 1183 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28924 1183 }
28925 else
28926 {
28927 //draw only hero. otherwise black layers might cover him.
28928 595 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28929 595 draw(framebuf);
28930 595 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28931 }
28932 }
28933 2032 }
28934
28935
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24 times.
792 else if(f<350)//draw 'GAME OVER' text
28936 {
28937
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
768 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
28938 {
28939 Quit = qRELOAD;
28940 skipcont = 1;
28941 clear_bitmap(framebuf);
28942 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28943 }
28944
2/4
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
768 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
28945 {
28946 Quit = qCONT;
28947 skipcont = 1;
28948 clear_bitmap(framebuf);
28949 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28950 }
28951 else
28952 {
28953 768 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
28954 768 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28955 768 textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
28956 }
28957 768 }
28958 else
28959 {
28960 24 clear_bitmap(framebuf);
28961 }
28962
28963 //SFX... put them all here
28964
4/4
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 8 times.
2824 switch(f)
28965 {
28966 case 0:
28967 8 sfx(getHurtSFX(),pan(x.getInt()));
28968 8 break;
28969 //Death sound.
28970 case 60:
28971 8 sfx(WAV_SPIRAL);
28972 8 break;
28973 //Message sound.
28974 case 194:
28975 8 sfx(WAV_MSG);
28976 8 break;
28977 }
28978 //adv:
28979 2824 advanceframe(true);
28980 2824 ++f;
28981 //if (!player_doscript ) ++f;
28982
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 8 times.
5648 }
28983
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2816 times.
2824 while(f<353 && !Quit);
28984
28985 8 destroy_bitmap(subscrbmp);
28986 8 action=none; FFCore.setHeroAction(none);
28987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if ( dontdraw < 2 ) { dontdraw=0; }
28988 8 }
28989
28990
28991 3 void HeroClass::ganon_intro()
28992 {
28993 /*
28994 ************************
28995 * GANON INTRO SEQUENCE *
28996 ************************
28997 -25 DOT updates
28998 -24 HERO in
28999 0 TRIFORCE overhead - code begins at this point (f == 0)
29000 47 GANON in
29001 58 LIGHT step
29002 68 LIGHT step
29003 78 LIGHT step
29004 255 TRIFORCE out
29005 256 TRIFORCE in
29006 270 TRIFORCE out
29007 271 GANON out, HERO face up
29008 */
29009 3 loaded_guys=true;
29010 3 loaditem();
29011
29012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(game->lvlitems[dlevel]&liBOSS)
29013 {
29014 return;
29015 }
29016
29017 3 dir=down;
29018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( !isSideViewHero() )
29019 {
29020 3 fall = 0; //Fix midair glitch on holding triforce. -Z
29021 3 fakefall = 0;
29022 3 z = 0;
29023 3 fakez = 0;
29024 3 }
29025 3 action=landhold2; FFCore.setHeroAction(landhold2);
29026 3 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
29027 //not good, as this only returns the highest level that Hero possesses. -DD
29028 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
29029
29030
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 723 times.
✓ Branch 2 taken 723 times.
✓ Branch 3 taken 3 times.
726 for(int32_t f=0; f<271 && !Quit; f++)
29031 {
29032
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 3 times.
723 if(f==47)
29033 {
29034 3 music_stop();
29035 3 stop_sfx(WAV_ROAR);
29036 3 sfx(WAV_GASP);
29037 3 sfx(WAV_GANON);
29038 3 int32_t Id=0;
29039
29040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 237 times.
237 for(int32_t i=0; i<eMAXGUYS; i++)
29041 {
29042
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 3 times.
237 if(guysbuf[i].flags2&eneflag_ganon)
29043 {
29044 3 Id=i;
29045 3 break;
29046 }
29047 234 }
29048
29049
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(current_item(itype_ring))
29050 {
29051 2 addenemy(160,96,Id,0);
29052 2 }
29053 else
29054 {
29055 1 addenemy(80,32,Id,0);
29056 }
29057 3 }
29058
29059
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 3 times.
723 if(f==48)
29060 {
29061 3 lighting(true,true); // Hmm. -L
29062 3 f += 30;
29063 3 }
29064
29065 //NES Z1, the triforce vanishes for one frame in two cases
29066 //while still showing Hero's two-handed overhead sprite.
29067 //This should be a Quest Rule for NES Accuracy. -Z
29068
4/4
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 717 times.
723 if(f==255 || f==270)
29069 {
29070 6 holditem=-1;
29071 6 }
29072
29073
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 3 times.
723 if(f==256)
29074 {
29075 3 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
29076 3 }
29077
29078 723 draw_screen(tmpscr);
29079 723 advanceframe(true);
29080
29081
1/2
✓ Branch 0 taken 723 times.
✗ Branch 1 not taken.
723 if(rSbtn())
29082 {
29083 conveyclk=3;
29084 int32_t tmp_subscr_clk = frame;
29085 dosubscr(&QMisc);
29086 newscr_clk += frame - tmp_subscr_clk;
29087 }
29088
29089 723 }
29090
29091 3 action=none; FFCore.setHeroAction(none);
29092 3 dir=up;
29093
29094
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
3 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
29095 1 jukebox(MAXMIDIS-1);
29096 else
29097 2 playLevelMusic();
29098
29099 3 currcset=DMaps[currdmap].color;
29100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_bit(quest_rules, qr_GANONINTRO) )
29101 {
29102 3 dointro();
29103 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
29104 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
29105 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
29106 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
29107 3 }
29108 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
29109 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
29110 //on a different DMap.
29111 //~ Otherwise, why is it here?! -Z
29112
29113
29114 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
29115 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
29116
29117 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
29118 //Users who use that dmap rule should put ganons room on its own DMap! -Z
29119 3 cont_sfx(WAV_ROAR);
29120 3 }
29121
29122 2 void HeroClass::win_game()
29123 {
29124
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 replay_step_comment("win_game");
29125 2 Playing=Paused=false;
29126 2 action=won; FFCore.setHeroAction(won);
29127 2 Quit=qWON;
29128 2 hclk=0;
29129 2 x = 136;
29130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 y = (isdungeon() && currscr<128) ? 75 : 73;
29131 2 z = fakez = fall = fakefall = spins = 0;
29132 2 dir=left;
29133 2 }
29134
29135 5267 void HeroClass::reset_swordcharge()
29136 {
29137 5267 charging=spins=tapping=0;
29138 5267 }
29139
29140 5711 void HeroClass::reset_hookshot()
29141 {
29142
10/12
✓ Branch 0 taken 5286 times.
✓ Branch 1 taken 425 times.
✓ Branch 2 taken 5282 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 5263 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 5260 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 5260 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 5260 times.
5711 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
29143 {
29144 5260 action=none; FFCore.setHeroAction(none);
29145 5260 }
29146
29147 5711 hookshot_frozen=false;
29148 5711 hookshot_used=false;
29149 5711 pull_hero=false;
29150 5711 hs_fix=false;
29151 5711 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
29152 5711 switch_hooked = false;
29153
1/2
✓ Branch 0 taken 5711 times.
✗ Branch 1 not taken.
5711 if(switching_object)
29154 switching_object->switch_hooked = false;
29155 5711 switching_object = NULL;
29156 5711 hooked_combopos = -1;
29157 5711 switchhook_cost_item = -1;
29158 5711 hooked_layerbits = 0;
29159
2/2
✓ Branch 0 taken 39977 times.
✓ Branch 1 taken 5711 times.
45688 for(auto q = 0; q < 7; ++q)
29160 39977 hooked_undercombos[q] = -1;
29161 5711 Lwpns.del(Lwpns.idFirst(wHSHandle));
29162 5711 Lwpns.del(Lwpns.idFirst(wHookshot));
29163 5711 chainlinks.clear();
29164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5711 times.
5711 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
29165 5711 hs_switcher = false;
29166
29167
2/2
✓ Branch 0 taken 5069 times.
✓ Branch 1 taken 642 times.
5711 if(index>=0)
29168 {
29169 642 stop_sfx(itemsbuf[index].usesound);
29170 642 }
29171
29172 5711 hs_xdist=0;
29173 5711 hs_ydist=0;
29174 5711 }
29175
29176
29177 619233 bool HeroClass::can_deploy_ladder()
29178 {
29179
2/2
✓ Branch 0 taken 309377 times.
✓ Branch 1 taken 309856 times.
748804 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
29180
4/4
✓ Branch 0 taken 180285 times.
✓ Branch 1 taken 129571 times.
✓ Branch 2 taken 52642 times.
✓ Branch 3 taken 76929 times.
309856 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
29181
8/10
✓ Branch 0 taken 436367 times.
✓ Branch 1 taken 182866 times.
✓ Branch 2 taken 402129 times.
✓ Branch 3 taken 34238 times.
✓ Branch 4 taken 402073 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 402073 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 402073 times.
1021306 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
29182
1/2
✓ Branch 0 taken 402073 times.
✗ Branch 1 not taken.
402073 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
29183 }
29184
29185 2384484 void HeroClass::reset_ladder()
29186 {
29187 2384484 ladderx=laddery=0;
29188 2384484 }
29189
29190 bool is_conveyor(int32_t type);
29191 int32_t get_conveyor(int32_t x, int32_t y);
29192
29193 2441644 void HeroClass::check_conveyor()
29194 {
29195 2441644 ++newconveyorclk;
29196
1/2
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
2441644 if (newconveyorclk < 0) newconveyorclk = 0;
29197
29198
14/18
✓ Branch 0 taken 2441644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441644 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2441452 times.
✓ Branch 5 taken 192 times.
✓ Branch 6 taken 2441452 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2441452 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2439646 times.
✓ Branch 11 taken 1806 times.
✓ Branch 12 taken 2439580 times.
✓ Branch 13 taken 66 times.
✓ Branch 14 taken 2439460 times.
✓ Branch 15 taken 120 times.
✓ Branch 16 taken 2439460 times.
✓ Branch 17 taken 120 times.
2441644 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
29199 {
29200 2184 is_conveyor_stunned = 0;
29201 2184 return;
29202 }
29203
29204 2439460 WalkflagInfo info;
29205 int32_t xoff,yoff;
29206 2439460 zfix deltax(0), deltay(0);
29207 2439460 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
29208
2/2
✓ Branch 0 taken 1627577 times.
✓ Branch 1 taken 811883 times.
2439460 if(cmbid < 0)
29209 {
29210
2/2
✓ Branch 0 taken 1627521 times.
✓ Branch 1 taken 56 times.
1627577 if (conveyclk <= 0) is_on_conveyor=false;
29211 1627577 return;
29212 }
29213 811883 newcombo const* cmb = &combobuf[cmbid];
29214 811883 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
29215 811883 bool custom_spd = (cmb->usrflags&cflag2);
29216
3/4
✓ Branch 0 taken 811778 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 811778 times.
✗ Branch 3 not taken.
811883 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
29217 {
29218 811883 int32_t ctype=cmb->type;
29219
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 811778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
811883 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
29220
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 811778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
811883 if(custom_spd && (newconveyorclk % rate)) return;
29221
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 811789 times.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
811883 if((cmb->usrflags&cflag5) && HasHeavyBoots())
29222 return;
29223 811883 is_on_conveyor=false;
29224 811883 is_conveyor_stunned=0;
29225
29226 811883 deltax=combo_class_buf[ctype].conveyor_x_speed;
29227 811883 deltay=combo_class_buf[ctype].conveyor_y_speed;
29228
29229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 811883 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
811883 if (is_conveyor(ctype) && custom_spd)
29230 {
29231 deltax = zslongToFix(cmb->attributes[0]);
29232 deltay = zslongToFix(cmb->attributes[1]);
29233 }
29234
29235
6/8
✓ Branch 0 taken 811883 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811883 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2096 times.
✓ Branch 5 taken 809787 times.
✓ Branch 6 taken 757 times.
✓ Branch 7 taken 1339 times.
811883 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
29236 {
29237 1339 cmbid = MAPCOMBO(x+8,y+16);
29238 1339 cmb = &combobuf[cmbid];
29239 1339 custom_spd = cmb->usrflags&cflag2;
29240 1339 ctype=(cmb->type);
29241 1339 deltax=combo_class_buf[ctype].conveyor_x_speed;
29242 1339 deltay=combo_class_buf[ctype].conveyor_y_speed;
29243
2/4
✓ Branch 0 taken 1339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1339 times.
✗ Branch 3 not taken.
1339 if ((deltax != 0 || deltay != 0) && custom_spd)
29244 {
29245 deltax = zslongToFix(cmb->attributes[0]);
29246 deltay = zslongToFix(cmb->attributes[1]);
29247 }
29248 1339 }
29249
29250
2/4
✓ Branch 0 taken 811883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 811883 times.
811883 if(deltax!=0||deltay!=0)
29251 {
29252 is_on_conveyor=true;
29253 }
29254 811883 else return;
29255
29256 bool movedx = false, movedy = false;
29257 if(cmb->usrflags&cflag4) //Smart corners
29258 {
29259 if(deltay<0)
29260 {
29261 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29262 execute(info);
29263
29264 if(!info.isUnwalkable())
29265 {
29266 movedy = true;
29267 zfix step(0);
29268
29269 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29270 {
29271 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29272 {
29273 yoff=int32_t(y-step)&7;
29274
29275 if(!yoff) break;
29276
29277 step++;
29278 }
29279 }
29280 else
29281 {
29282 step=abs(deltay);
29283 }
29284
29285 y=y-step;
29286 hs_starty-=step.getInt();
29287
29288 for(int32_t j=0; j<chainlinks.Count(); j++)
29289 {
29290 chainlinks.spr(j)->y-=step;
29291 }
29292
29293 if(Lwpns.idFirst(wHookshot)>-1)
29294 {
29295 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29296 }
29297
29298 if(Lwpns.idFirst(wHSHandle)>-1)
29299 {
29300 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29301 }
29302 }
29303 }
29304 else if(deltay>0)
29305 {
29306 info = walkflag(x,y+15+2,2,down);
29307 execute(info);
29308
29309 if(!info.isUnwalkable())
29310 {
29311 movedy = true;
29312 zfix step(0);
29313
29314 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29315 {
29316 while(step<abs(deltay))
29317 {
29318 yoff=int32_t(y+step)&7;
29319
29320 if(!yoff) break;
29321
29322 step++;
29323 }
29324 }
29325 else
29326 {
29327 step=abs(deltay);
29328 }
29329
29330 y=y+step;
29331 hs_starty+=step.getInt();
29332
29333 for(int32_t j=0; j<chainlinks.Count(); j++)
29334 {
29335 chainlinks.spr(j)->y+=step;
29336 }
29337
29338 if(Lwpns.idFirst(wHookshot)>-1)
29339 {
29340 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29341 }
29342
29343 if(Lwpns.idFirst(wHSHandle)>-1)
29344 {
29345 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29346 }
29347 }
29348 }
29349
29350 if(deltax<0)
29351 {
29352 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29353 execute(info);
29354
29355 if(!info.isUnwalkable())
29356 {
29357 movedx = true;
29358 zfix step(0);
29359
29360 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29361 {
29362 while(step<abs(deltax))
29363 {
29364 xoff=int32_t(x-step)&7;
29365
29366 if(!xoff) break;
29367
29368 step++;
29369 }
29370 }
29371 else
29372 {
29373 step=abs(deltax);
29374 }
29375
29376 x=x-step;
29377 hs_startx-=step.getInt();
29378
29379 for(int32_t j=0; j<chainlinks.Count(); j++)
29380 {
29381 chainlinks.spr(j)->x-=step;
29382 }
29383
29384 if(Lwpns.idFirst(wHookshot)>-1)
29385 {
29386 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29387 }
29388
29389 if(Lwpns.idFirst(wHSHandle)>-1)
29390 {
29391 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29392 }
29393 }
29394 }
29395 else if(deltax>0)
29396 {
29397 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29398 execute(info);
29399
29400 if(!info.isUnwalkable())
29401 {
29402 movedx = true;
29403 zfix step(0);
29404
29405 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29406 {
29407 while(step<abs(deltax))
29408 {
29409 xoff=int32_t(x+step)&7;
29410
29411 if(!xoff) break;
29412
29413 step++;
29414 }
29415 }
29416 else
29417 {
29418 step=abs(deltax);
29419 }
29420
29421 x=x+step;
29422 hs_startx+=step.getInt();
29423
29424 for(int32_t j=0; j<chainlinks.Count(); j++)
29425 {
29426 chainlinks.spr(j)->x+=step;
29427 }
29428
29429 if(Lwpns.idFirst(wHookshot)>-1)
29430 {
29431 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29432 }
29433
29434 if(Lwpns.idFirst(wHSHandle)>-1)
29435 {
29436 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29437 }
29438 }
29439 }
29440 if(deltax && !movedx)
29441 y = COMBOY(pos);
29442 if(deltay && !movedy)
29443 x = COMBOX(pos);
29444 }
29445 if(!movedy)
29446 {
29447 if(deltay<0)
29448 {
29449 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29450 execute(info);
29451
29452 if(!info.isUnwalkable())
29453 {
29454 movedy = true;
29455 zfix step(0);
29456
29457 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29458 {
29459 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29460 {
29461 yoff=int32_t(y-step)&7;
29462
29463 if(!yoff) break;
29464
29465 step++;
29466 }
29467 }
29468 else
29469 {
29470 step=abs(deltay);
29471 }
29472
29473 y=y-step;
29474 hs_starty-=step.getInt();
29475
29476 for(int32_t j=0; j<chainlinks.Count(); j++)
29477 {
29478 chainlinks.spr(j)->y-=step;
29479 }
29480
29481 if(Lwpns.idFirst(wHookshot)>-1)
29482 {
29483 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29484 }
29485
29486 if(Lwpns.idFirst(wHSHandle)>-1)
29487 {
29488 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29489 }
29490 }
29491 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
29492 }
29493 else if(deltay>0)
29494 {
29495 info = walkflag(x,y+15+2,2,down);
29496 execute(info);
29497
29498 if(!info.isUnwalkable())
29499 {
29500 movedy = true;
29501 zfix step(0);
29502
29503 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29504 {
29505 while(step<abs(deltay))
29506 {
29507 yoff=int32_t(y+step)&7;
29508
29509 if(!yoff) break;
29510
29511 step++;
29512 }
29513 }
29514 else
29515 {
29516 step=abs(deltay);
29517 }
29518
29519 y=y+step;
29520 hs_starty+=step.getInt();
29521
29522 for(int32_t j=0; j<chainlinks.Count(); j++)
29523 {
29524 chainlinks.spr(j)->y+=step;
29525 }
29526
29527 if(Lwpns.idFirst(wHookshot)>-1)
29528 {
29529 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29530 }
29531
29532 if(Lwpns.idFirst(wHSHandle)>-1)
29533 {
29534 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29535 }
29536 }
29537 else checkdamagecombos(x,y+15);
29538 }
29539 }
29540 if(!movedx)
29541 {
29542 if(deltax<0)
29543 {
29544 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29545 execute(info);
29546
29547 if(!info.isUnwalkable())
29548 {
29549 movedx = true;
29550 zfix step(0);
29551
29552 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29553 {
29554 while(step<abs(deltax))
29555 {
29556 xoff=int32_t(x-step)&7;
29557
29558 if(!xoff) break;
29559
29560 step++;
29561 }
29562 }
29563 else
29564 {
29565 step=abs(deltax);
29566 }
29567
29568 x=x-step;
29569 hs_startx-=step.getInt();
29570
29571 for(int32_t j=0; j<chainlinks.Count(); j++)
29572 {
29573 chainlinks.spr(j)->x-=step;
29574 }
29575
29576 if(Lwpns.idFirst(wHookshot)>-1)
29577 {
29578 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29579 }
29580
29581 if(Lwpns.idFirst(wHSHandle)>-1)
29582 {
29583 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29584 }
29585 }
29586 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
29587 }
29588 else if(deltax>0)
29589 {
29590 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29591 execute(info);
29592
29593 if(!info.isUnwalkable())
29594 {
29595 movedx = true;
29596 zfix step(0);
29597
29598 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29599 {
29600 while(step<abs(deltax))
29601 {
29602 xoff=int32_t(x+step)&7;
29603
29604 if(!xoff) break;
29605
29606 step++;
29607 }
29608 }
29609 else
29610 {
29611 step=abs(deltax);
29612 }
29613
29614 x=x+step;
29615 hs_startx+=step.getInt();
29616
29617 for(int32_t j=0; j<chainlinks.Count(); j++)
29618 {
29619 chainlinks.spr(j)->x+=step;
29620 }
29621
29622 if(Lwpns.idFirst(wHookshot)>-1)
29623 {
29624 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29625 }
29626
29627 if(Lwpns.idFirst(wHSHandle)>-1)
29628 {
29629 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29630 }
29631 }
29632 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
29633 }
29634 }
29635 if(movedx || movedy)
29636 {
29637 if(cmb->usrflags&cflag1)
29638 is_conveyor_stunned = rate;
29639 if(cmb->usrflags&cflag3)
29640 {
29641 if(abs(deltax) > abs(deltay))
29642 dir = (deltax > 0) ? right : left;
29643 else dir = (deltay > 0) ? down : up;
29644 }
29645 }
29646 }
29647 2441644 }
29648
29649 void HeroClass::setNayrusLoveShieldClk(int32_t newclk)
29650 {
29651 NayrusLoveShieldClk=newclk;
29652
29653 if(decorations.idCount(dNAYRUSLOVESHIELD)==0)
29654 {
29655 decoration *dec;
29656 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29657 decorations.spr(decorations.Count()-1)->misc=0;
29658 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29659 dec=(decoration *)decorations.spr(decorations.Count()-1);
29660 decorations.spr(decorations.Count()-1)->misc=1;
29661 }
29662 }
29663
29664 4528 int32_t HeroClass::getNayrusLoveShieldClk()
29665 {
29666 4528 return NayrusLoveShieldClk;
29667 }
29668
29669 int32_t HeroClass::getHoverClk()
29670 {
29671 return hoverclk;
29672 }
29673
29674 798564 int32_t HeroClass::getHoldClk()
29675 {
29676 798564 return holdclk;
29677 }
29678
29679 2475470 int32_t HeroClass::getLastLensID(){
29680 2475470 return last_lens_id;
29681 }
29682
29683 40 void HeroClass::setLastLensID(int32_t p_item){
29684 40 last_lens_id = p_item;
29685 40 }
29686
29687 20131459 bool HeroClass::getOnSideviewLadder()
29688 {
29689 20131459 return on_sideview_ladder;
29690 }
29691
29692 52 void HeroClass::setOnSideviewLadder(bool val)
29693 {
29694
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 7 times.
52 if(val)
29695 {
29696 7 fall = fakefall = hoverclk = jumping = 0;
29697 7 hoverflags = 0;
29698 7 inair = false;
29699 7 }
29700 52 on_sideview_ladder = val;
29701 52 }
29702
29703 763015 bool HeroClass::canSideviewLadder(bool down)
29704 {
29705
2/2
✓ Branch 0 taken 761763 times.
✓ Branch 1 taken 1252 times.
763015 if(!isSideViewHero()) return false;
29706
1/2
✓ Branch 0 taken 1252 times.
✗ Branch 1 not taken.
1252 if(jumping < 0) return false;
29707
3/4
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 943 times.
✓ Branch 2 taken 309 times.
✗ Branch 3 not taken.
1252 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29708 {
29709 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29710 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
29711 }
29712 //Are you presently able to climb a sideview ladder?
29713 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29714 //y+0 checks your top-half for large hitbox; y+8 for small
29715 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29716 //y+16 check is for going down onto a ladder you are standing on.
29717
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 504 times.
1970 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
29718
4/4
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 646 times.
✓ Branch 3 taken 72 times.
748 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
29719
6/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 642 times.
✓ Branch 2 taken 333 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 305 times.
✓ Branch 5 taken 4 times.
955 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
29720 763015 }
29721
29722 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
29723 {
29724 if(!isSideViewHero()) return false;
29725 if(jumping < 0) return false;
29726 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29727 {
29728 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29729 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
29730 }
29731 //Are you presently able to climb a sideview ladder?
29732 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29733 //y+0 checks your top-half for large hitbox; y+8 for small
29734 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29735 //y+16 check is for going down onto a ladder you are standing on.
29736 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
29737 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
29738 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
29739 }
29740
29741 1459701 void HeroClass::execute(HeroClass::WalkflagInfo info)
29742 {
29743 1459701 int32_t flags = info.getFlags();
29744
29745
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1459557 times.
1459701 if(flags & WalkflagInfo::CLEARILSWIM)
29746 144 ilswim =false;
29747
2/2
✓ Branch 0 taken 1459525 times.
✓ Branch 1 taken 32 times.
1459557 else if(flags & WalkflagInfo::SETILSWIM)
29748 32 ilswim = true;
29749
29750
1/2
✓ Branch 0 taken 1459701 times.
✗ Branch 1 not taken.
1459701 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
29751 {
29752 charging = 0;
29753 attackclk = 0;
29754 }
29755
29756
1/2
✓ Branch 0 taken 1459701 times.
✗ Branch 1 not taken.
1459701 if(flags & WalkflagInfo::SETDIR)
29757 {
29758 dir = info.getDir();
29759 }
29760
29761
2/2
✓ Branch 0 taken 1459636 times.
✓ Branch 1 taken 65 times.
1459701 if(flags & WalkflagInfo::SETHOPCLK)
29762 {
29763 65 hopclk = info.getHopClk();
29764 65 }
29765
29766
2/2
✓ Branch 0 taken 1459669 times.
✓ Branch 1 taken 32 times.
1459701 if(flags & WalkflagInfo::SETHOPDIR)
29767 {
29768 32 hopdir = info.getHopDir();
29769 32 }
29770
29771 1459701 }
29772
29773 3088437 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
29774 {
29775 3088437 HeroClass::WalkflagInfo ret;
29776 3088437 ret.newhopclk = newhopclk;
29777 3088437 ret.newdir = newdir;
29778
2/2
✓ Branch 0 taken 2468283 times.
✓ Branch 1 taken 620154 times.
3088437 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29779
29780 3088437 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
29781 3088437 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
29782 3088437 ret.flags = flags1 | flags2;
29783 3088437 return ret;
29784 }
29785
29786 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
29787 {
29788 HeroClass::WalkflagInfo ret;
29789 ret.newhopclk = newhopclk;
29790 ret.newdir = newdir;
29791 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29792
29793 ret.flags = flags & other.flags;
29794 return ret;
29795 }
29796
29797 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
29798 {
29799 HeroClass::WalkflagInfo ret;
29800 ret.newhopclk = newhopclk;
29801 ret.newdir = newdir;
29802 ret.newhopdir = newhopdir;
29803
29804 ret.flags = flags ^ UNWALKABLE;
29805 return ret;
29806 }
29807
29808 void HeroClass::explode(int32_t type)
29809 {
29810 static int32_t tempx, tempy;
29811 static byte herotilebuf[256];
29812 int32_t ltile=0;
29813 int32_t lflip=0;
29814 bool shieldModify=true;
29815 unpack_tile(newtilebuf, tile, flip, true);
29816 memcpy(herotilebuf, unpackbuf, 256);
29817 tempx=Hero.getX();
29818 tempy=Hero.getY();
29819 for(int32_t i=0; i<16; ++i)
29820 {
29821 for(int32_t j=0; j<16; ++j)
29822 {
29823 if(herotilebuf[i*16+j])
29824 {
29825 if(type==0) // Twilight
29826 {
29827 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
29828 int32_t k=particles.Count()-1;
29829 particle *p = (particles.at(k));
29830 p->step=3;
29831 }
29832 else if(type ==1) // Sands of Hours
29833 {
29834 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
29835 int32_t k=particles.Count()-1;
29836 particle *p = (particles.at(k));
29837 p->step=4;
29838
29839 if(zc_oldrand()%10 < 2)
29840 {
29841 p->color=1;
29842 p->cset=0;
29843 }
29844 }
29845 else
29846 {
29847 particles.add(new pFaroresWindDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
29848
29849 int32_t k=particles.Count()-1;
29850 particle *p = (particles.at(k));
29851 p->angular=true;
29852 p->angle=zc_oldrand();
29853 p->step=(((double)j)/8);
29854 p->yofs=Hero.getYOfs();
29855 }
29856 }
29857 }
29858 }
29859 }
29860
29861 137 void HeroClass::SetSwim()
29862 {
29863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 if (CanSideSwim())
29864 {
29865 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
29866 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29867 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
29868 }
29869 137 else {action=swimming; FFCore.setHeroAction(swimming);}
29870 137 }
29871
29872 31085 void HeroClass::SetAttack()
29873 {
29874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31085 times.
31085 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29875 31085 else {action=attacking; FFCore.setHeroAction(attacking);}
29876 31085 }
29877
29878 20068232 bool HeroClass::IsSideSwim()
29879 {
29880
6/12
✓ Branch 0 taken 20068232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20068232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20068232 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20068232 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20068232 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 20068232 times.
20068232 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
29881 }
29882
29883 593587 bool HeroClass::CanSideSwim()
29884 {
29885
1/2
✓ Branch 0 taken 593587 times.
✗ Branch 1 not taken.
593587 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
29886 }
29887
29888 1769588 int32_t HeroClass::getTileModifier()
29889 {
29890 1769588 return item_tile_mod() + bunny_tile_mod();
29891 }
29892 void HeroClass::setImmortal(int32_t nimmortal)
29893 {
29894 immortal = nimmortal;
29895 }
29896 void HeroClass::kill(bool bypassFairy)
29897 {
29898 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
29899 }
29900 4890208 bool HeroClass::sideview_mode() const
29901 {
29902
3/4
✓ Branch 0 taken 16318 times.
✓ Branch 1 taken 4873890 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16318 times.
4890208 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
29903 }
29904 3851 bool HeroClass::is_unpushable() const
29905 {
29906 3851 return toogam;
29907 }
29908 /*** end of hero.cpp ***/
29909
29910
29911
29912
29913